Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-12-17 01:08:07
Exec Total Coverage
Lines: 1270 3887 32.7%
Functions: 113 337 33.5%
Branches: 633 2764 22.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 14 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
14 bool is_sys_pal = false;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109 //extern byte refresh_select_screen;
110 //extern movingblock mblock2; //mblock[4]?
111 //extern int32_t db;
112
113 static const char *ZC_str = "Zelda Classic";
114 extern char save_file_name[1024];
115 #ifdef ALLEGRO_DOS
116 const char *qst_dir_name = "dos_qst_dir";
117 #elif defined(ALLEGRO_WINDOWS)
118 const char *qst_dir_name = "win_qst_dir";
119 static const char *qst_module_name = "current_module";
120 #elif defined(ALLEGRO_LINUX)
121 const char *qst_dir_name = "linux_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(__APPLE__)
124 const char *qst_dir_name = "osx_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #endif
127 #ifdef ALLEGRO_LINUX
128 static const char *samplepath = "samplesoundset/patches.dat";
129 #endif
130 char qst_files_path[2048];
131
132 #ifdef _MSC_VER
133 #define getcwd _getcwd
134 #endif
135
136 bool rF11();
137 bool rI();
138 bool rQ();
139 bool zc_key_pressed();
140
141 #ifdef _WIN32
142
143 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
144 extern "C"
145 {
146 typedef HRESULT(WINAPI *t_DwmFlush)();
147 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
148 }
149
150 void do_DwmFlush()
151 {
152 static HMODULE shell = LoadLibrary("dwmapi.dll");
153
154 if(!shell)
155 return;
156
157 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
158 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
159
160 BOOL enabled;
161 isEnabled(&enabled);
162
163 if(isEnabled)
164 flush();
165 }
166
167 #endif // _WIN32
168
169 // Dialogue largening
170 void large_dialog(DIALOG *d)
171 {
172 large_dialog(d, 1.5);
173 }
174
175 void large_dialog(DIALOG *d, float RESIZE_AMT)
176 {
177 if(!d[0].d1)
178 {
179 d[0].d1 = 1;
180 int32_t oldwidth = d[0].w;
181 int32_t oldheight = d[0].h;
182 int32_t oldx = d[0].x;
183 int32_t oldy = d[0].y;
184 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
185 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
186 d[0].w = int32_t(d[0].w*RESIZE_AMT);
187 d[0].h = int32_t(d[0].h*RESIZE_AMT);
188
189 for(int32_t i=1; d[i].proc !=NULL; i++)
190 {
191 // Place elements horizontally
192 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
193 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
194
195 if(d[i].proc != d_stringloader)
196 {
197 if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].w *= 2;
200 }
201 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
202 }
203
204 // Place elements vertically
205 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
206 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
207
208 // Vertically resize elements
209 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
210 {
211 d[i].h = int32_t((double)d[i].h*1.5);
212 }
213 else if(d[i].proc == jwin_droplist_proc)
214 {
215 d[i].y += int32_t((double)d[i].h*0.25);
216 d[i].h = int32_t((double)d[i].h*1.25);
217 }
218 else if(d[i].proc==d_bitmap_proc)
219 {
220 d[i].h *= 2;
221 }
222 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
223
224 // Fix frames
225 if(d[i].proc == jwin_frame_proc)
226 {
227 d[i].x++;
228 d[i].y++;
229 d[i].w-=4;
230 d[i].h-=4;
231 }
232 }
233 }
234
235 for(int32_t i=1; d[i].proc!=NULL; i++)
236 {
237 if(d[i].proc==jwin_slider_proc)
238 continue;
239
240 // Bigger font
241 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
242
243 if(!d[i].dp2 && bigfontproc)
244 {
245 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
246 d[i].dp2 = lfont_l;
247 }
248 else if(!bigfontproc)
249 {
250 // ((ListData *)d[i].dp)->font = &sfont3;
251 ((ListData *)d[i].dp)->font = &lfont_l;
252 }
253
254 // Make checkboxes work
255 if(d[i].proc == jwin_check_proc)
256 d[i].proc = jwin_checkfont_proc;
257 else if(d[i].proc == jwin_radio_proc)
258 d[i].proc = jwin_radiofont_proc;
259 }
260
261 jwin_center_dialog(d);
262 }
263
264
265 /**********************************/
266 /******** System functions ********/
267 /**********************************/
268
269 static char cfg_sect[] = "zeldadx"; //We need to rename this.
270 static char ctrl_sect[] = "Controls";
271 static char sfx_sect[] = "Volume";
272
273 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
274 {
275 return D_O_K;
276 }
277
278 14 void load_game_configs()
279 {
280 14 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
281 14 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
282 14 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
283 14 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
284 14 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
285 14 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
286 14 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
287 14 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
288 14 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
289 14 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
290 14 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
291 14 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
292 14 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
293 14 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
294 14 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
295
296 //cheat modifier keya
297 14 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
298 14 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
299 14 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
300 14 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
301
302
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
303 joystick_index = 0;
304
305 14 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
306 14 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
307 14 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
308 14 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
309 14 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
310 14 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
311 14 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
312 14 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
313 14 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
314 14 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
315
316 14 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
317 14 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
318 14 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
319 14 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
320
321 14 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
322 14 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
323 14 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
324 14 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
325 14 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
326 14 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
327 14 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
328 14 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
329 14 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
330 14 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
331 14 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
332
333 14 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
334 14 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
335 14 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
336 14 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
337
338 14 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
339
340 14 digi_volume = zc_get_config(sfx_sect,"digi",248);
341 14 midi_volume = zc_get_config(sfx_sect,"midi",255);
342 14 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
343 14 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
344 14 pan_style = zc_get_config(sfx_sect,"pan",1);
345 // 1 <= zcmusic_bufsz <= 128
346 14 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
347 14 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
348 14 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
349 14 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
350 14 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
351 14 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
352 14 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
353 #ifdef __EMSCRIPTEN__
354 if (em_is_mobile()) NameEntryMode = 2;
355 #endif
356 14 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
357 14 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
358 14 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
359 14 title_version = zc_get_config(cfg_sect,"title",2);
360 14 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
361 14 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
362
363 //default - scale x2, 640 x 480
364 14 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
365 14 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
366 14 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
367 14 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
368 14 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
369
370 14 loadlast = zc_get_config(cfg_sect,"load_last",0);
371
372 14 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
373
374 14 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
375
376 //workaround for the 100% CPU bug. -Gleeok
377 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
378 14 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
379 #else
380 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
381 #endif
382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 frame_rest_suggest = zc_min(2, frame_rest_suggest);
383
384 14 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
385
386 #ifdef _WIN32
387 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
388 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
389 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
390 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
391
392 // This one's for Aero
393 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
394
395 // And this one fixes patches unloading on some MIDI setups
396 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
397 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
398 #else //UNIX
399 14 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
400 14 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
401 14 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
402 #endif
403 14 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
404
405 14 char const* default_path = "";
406 14 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
407
408
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(strlen(qstdir)==0)
409 {
410 14 getcwd(qstdir,2048);
411 14 fix_filename_case(qstdir);
412 14 fix_filename_slashes(qstdir);
413 14 put_backslash(qstdir);
414 14 }
415 else
416 {
417 chop_path(qstdir);
418 }
419
420 14 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
421 14 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
422 14 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
423 14 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
424 14 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
425 14 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
426 14 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
427 14 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
428 14 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
429 14 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
430 14 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
431 14 }
432
433 void save_control_configs(bool kb)
434 {
435 if(kb)
436 {
437 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
438 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
439 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
440 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
441
442 if (!replay_is_replaying())
443 {
444 zc_set_config(ctrl_sect,"key_a",Akey);
445 zc_set_config(ctrl_sect,"key_b",Bkey);
446 zc_set_config(ctrl_sect,"key_s",Skey);
447 zc_set_config(ctrl_sect,"key_l",Lkey);
448 zc_set_config(ctrl_sect,"key_r",Rkey);
449 zc_set_config(ctrl_sect,"key_p",Pkey);
450 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
451 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
452 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
453 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
454 zc_set_config(ctrl_sect,"key_up", DUkey);
455 zc_set_config(ctrl_sect,"key_down", DDkey);
456 zc_set_config(ctrl_sect,"key_left", DLkey);
457 zc_set_config(ctrl_sect,"key_right",DRkey);
458 }
459 }
460 else
461 {
462 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
463 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
464 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
465 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
466 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
467 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
468 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
469 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
470 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
471 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
472 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
473 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
474 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
475 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
476
477 zc_set_config(ctrl_sect,"btn_a",Abtn);
478 zc_set_config(ctrl_sect,"btn_b",Bbtn);
479 zc_set_config(ctrl_sect,"btn_s",Sbtn);
480 zc_set_config(ctrl_sect,"btn_m",Mbtn);
481 zc_set_config(ctrl_sect,"btn_l",Lbtn);
482 zc_set_config(ctrl_sect,"btn_r",Rbtn);
483 zc_set_config(ctrl_sect,"btn_p",Pbtn);
484 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
485 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
486 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
487 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
488
489 zc_set_config(ctrl_sect,"btn_up",DUbtn);
490 zc_set_config(ctrl_sect,"btn_down",DDbtn);
491 zc_set_config(ctrl_sect,"btn_left",DLbtn);
492 zc_set_config(ctrl_sect,"btn_right",DRbtn);
493 }
494 }
495
496 void save_game_configs()
497 {
498 packfile_password("");
499
500 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
501
502 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
503 {
504 int o_window_x, o_window_y;
505 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
506 zc_set_config(cfg_sect,"window_x",o_window_x);
507 zc_set_config(cfg_sect,"window_y",o_window_y);
508 }
509
510 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
511 {
512 double monitor_scale = zc_get_monitor_scale();
513 window_width = al_get_display_width(all_get_display()) / monitor_scale;
514 window_height = al_get_display_height(all_get_display()) / monitor_scale;
515 zc_set_config(cfg_sect,"window_width",window_width);
516 zc_set_config(cfg_sect,"window_height",window_height);
517 }
518
519 zc_set_config(cfg_sect,"load_last",loadlast);
520 chop_path(qstdir);
521 zc_set_config(cfg_sect,qst_dir_name,qstdir);
522 zc_set_config("SAVEFILE","save_filename",save_file_name);
523 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
524 zc_set_config(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
525
526 flush_config_file();
527 #ifdef __EMSCRIPTEN__
528 em_sync_fs();
529 #endif
530 }
531
532 //----------------------------------------------------------------
533
534 // Timers
535
536 293 void fps_callback()
537 {
538 293 lastfps=framecnt;
539 293 dword tempsecs = fps_secs;
540 293 ++tempsecs;
541 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
542 293 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
543 293 ++fps_secs;
544 293 framecnt=0;
545 293 }
546
547 END_OF_FUNCTION(fps_callback)
548
549 14 int32_t Z_init_timers()
550 {
551 static bool didit = false;
552 const static char *err_str = "Couldn't allocate timer";
553 14 err_str = err_str; //Unused variable warning
554
555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(didit)
556 return 1;
557
558 14 didit = true;
559
560 LOCK_VARIABLE(lastfps);
561 LOCK_VARIABLE(framecnt);
562 LOCK_FUNCTION(fps_callback);
563
564
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
565 return 0;
566
567 14 return 1;
568 14 }
569
570 void Z_remove_timers()
571 {
572 remove_int(fps_callback);
573 }
574
575 //----------------------------------------------------------------
576
577 void go()
578 {
579 scare_mouse();
580 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
581 unscare_mouse();
582 }
583
584 void comeback()
585 {
586 scare_mouse();
587 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
588 unscare_mouse();
589 }
590
591 void dump_pal(BITMAP *dest)
592 {
593 for(int32_t i=0; i<256; i++)
594 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
595 }
596
597 //----------------------------------------------------------------
598
599 //Handles converting the mouse sprite from the .dat file
600 14 void load_mouse()
601 {
602 14 system_pal();
603 14 scare_mouse();
604 14 set_mouse_sprite(NULL);
605
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
606
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 14 times.
70 for(int32_t j = 0; j < 4; ++j)
607 {
608 56 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
609 56 BITMAP* subbmp = create_bitmap_ex(8,16,16);
610
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(zcmouse[j])
611 destroy_bitmap(zcmouse[j]);
612 56 zcmouse[j] = create_bitmap_ex(8,sz,sz);
613 56 clear_bitmap(zcmouse[j]);
614 56 clear_bitmap(tmpbmp);
615 56 clear_bitmap(subbmp);
616 56 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
617
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 56 times.
952 for(int32_t x = 0; x < 16; ++x)
618 {
619
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 896 times.
15232 for(int32_t y = 0; y < 16; ++y)
620 {
621 14336 int32_t color = getpixel(tmpbmp, x, y);
622
5/5
✓ Branch 0 taken 13188 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 308 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 252 times.
14336 switch(color)
623 {
624 case dvc(1):
625 266 color = jwin_pal[jcCURSORMISC];
626 266 break;
627 case dvc(2):
628 308 color = jwin_pal[jcCURSOROUTLINE];
629 308 break;
630 case dvc(3):
631 322 color = jwin_pal[jcCURSORLIGHT];
632 322 break;
633 case dvc(5):
634 252 color = jwin_pal[jcCURSORDARK];
635 252 break;
636 }
637 14336 putpixel(subbmp, x, y, color);
638 14336 }
639 896 }
640
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(sz!=16)
641 56 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
642 else
643 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
644 56 destroy_bitmap(tmpbmp);
645 56 destroy_bitmap(subbmp);
646 56 }
647 14 set_mouse_sprite(zcmouse[0]);
648
649 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
650 14 set_palette(*hw_palette);
651 14 show_mouse(screen);
652 14 show_mouse(NULL);
653
654 14 unscare_mouse();
655 14 game_pal();
656 14 }
657
658 // sets the video mode and initializes the palette and mouse sprite
659 14 bool game_vid_mode(int32_t mode,int32_t wait)
660 {
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
662 {
663 return false;
664 }
665
666 14 scrx = (resx-320)>>1;
667 14 scry = (resy-240)>>1;
668
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 14 times.
70 for(int32_t q = 0; q < 4; ++q)
669 56 zcmouse[q] = NULL;
670 14 load_mouse();
671 14 set_mouse_sprite(zcmouse[0]);
672
673
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 14 times.
238 for(int32_t i=240; i<256; i++)
674 224 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
675
676 14 set_palette(RAMpal);
677 14 clear_to_color(screen,BLACK);
678
679 14 rest(wait);
680 14 return true;
681 14 }
682
683 void null_quest()
684 {
685 char qstdat_string[2048];
686 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
687 strcat(qstdat_string,"#NESQST_NEW_QST");
688
689 #ifdef __EMSCRIPTEN__
690 // The quest template data file is not included because it's really big and isn't really needed
691 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
692 // which is much smaller.
693 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
694 #endif
695
696 byte skip_flags[4] = { 0 };
697
698 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
699 }
700
701 void init_NES_mode()
702 {
703 /*
704 // qst.dat may not load correctly without this...
705 QHeader.templatepath[0]='\0';
706
707 if(!init_colordata(true, &QHeader, &QMisc))
708 {
709 return;
710 }
711
712 loadfullpal();
713 init_tiles(false, &QHeader);
714 */
715 null_quest();
716 }
717
718 //----------------------------------------------------------------
719
720 qword trianglelines[16]=
721 {
722 0x0000000000000000ULL,
723 0xFD00000000000000ULL,
724 0xFDFD000000000000ULL,
725 0xFDFDFD0000000000ULL,
726 0xFDFDFDFD00000000ULL,
727 0xFDFDFDFDFD000000ULL,
728 0xFDFDFDFDFDFD0000ULL,
729 0xFDFDFDFDFDFDFD00ULL,
730 0xFDFDFDFDFDFDFDFDULL,
731 0x00FDFDFDFDFDFDFDULL,
732 0x0000FDFDFDFDFDFDULL,
733 0x000000FDFDFDFDFDULL,
734 0x00000000FDFDFDFDULL,
735 0x0000000000FDFDFDULL,
736 0x000000000000FDFDULL,
737 0x00000000000000FDULL,
738 };
739
740 word screen_triangles[28][32];
741 /*
742 qword triangles[4][16]= //[direction][value]
743 {
744 {
745 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
746 },
747 {
748 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
749 },
750 {
751 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
752 },
753 {
754 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
755 }
756 };
757 */
758
759
760 /*
761 byte triangles[4][16][8]= //[direction][value][line]
762 {
763 {
764 {
765 0, 0, 0, 0, 0, 0, 0, 0
766 },
767 {
768 1, 0, 0, 0, 0, 0, 0, 0
769 },
770 {
771 2, 1, 0, 0, 0, 0, 0, 0
772 },
773 {
774 3, 2, 1, 0, 0, 0, 0, 0
775 },
776 {
777 4, 3, 2, 1, 0, 0, 0, 0
778 },
779 {
780 5, 4, 3, 2, 1, 0, 0, 0
781 },
782 {
783 6, 5, 4, 3, 2, 1, 0, 0
784 },
785 {
786 7, 6, 5, 4, 3, 2, 1, 0
787 },
788 {
789 8, 7, 6, 5, 4, 3, 2, 1
790 },
791 {
792 8, 8, 7, 6, 5, 4, 3, 2
793 },
794 {
795 8, 8, 8, 7, 6, 5, 4, 3
796 },
797 {
798 8, 8, 8, 8, 7, 6, 5, 4
799 },
800 {
801 8, 8, 8, 8, 8, 7, 6, 5
802 },
803 {
804 8, 8, 8, 8, 8, 8, 7, 6
805 },
806 {
807 8, 8, 8, 8, 8, 8, 8, 7
808 },
809 {
810 8, 8, 8, 8, 8, 8, 8, 8
811 }
812 },
813 {
814 {
815 0, 0, 0, 0, 0, 0, 0, 0
816 },
817 {
818 15, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 14, 15, 0, 0, 0, 0, 0, 0
822 },
823 {
824 13, 14, 15, 0, 0, 0, 0, 0
825 },
826 {
827 12, 13, 14, 15, 0, 0, 0, 0
828 },
829 {
830 11, 12, 13, 14, 15, 0, 0, 0
831 },
832 {
833 10, 11, 12, 13, 14, 15, 0, 0
834 },
835 {
836 9, 10, 11, 12, 13, 14, 15, 0
837 },
838 {
839 8, 9, 10, 11, 12, 13, 14, 15
840 },
841 {
842 8, 8, 9, 10, 11, 12, 13, 14
843 },
844 {
845 8, 8, 8, 9, 10, 11, 12, 13
846 },
847 {
848 8, 8, 8, 8, 9, 10, 11, 12
849 },
850 {
851 8, 8, 8, 8, 8, 9, 10, 11
852 },
853 {
854 8, 8, 8, 8, 8, 8, 9, 10
855 },
856 {
857 8, 8, 8, 8, 8, 8, 8, 9
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 8
861 }
862 },
863 {
864 {
865 0, 0, 0, 0, 0, 0, 0, 0
866 },
867 {
868 0, 0, 0, 0, 0, 0, 0, 1
869 },
870 {
871 0, 0, 0, 0, 0, 0, 1, 2
872 },
873 {
874 0, 0, 0, 0, 0, 1, 2, 3
875 },
876 {
877 0, 0, 0, 0, 1, 2, 3, 4
878 },
879 {
880 0, 0, 0, 1, 2, 3, 4, 5
881 },
882 {
883 0, 0, 1, 2, 3, 4, 5, 6
884 },
885 {
886 0, 1, 2, 3, 4, 5, 6, 7
887 },
888 {
889 1, 2, 3, 4, 5, 6, 7, 8
890 },
891 {
892 2, 3, 4, 5, 6, 7, 8, 8
893 },
894 {
895 3, 4, 5, 6, 7, 8, 8, 8
896 },
897 {
898 4, 5, 6, 7, 8, 8, 8, 8
899 },
900 {
901 5, 6, 7, 8, 8, 8, 8, 8
902 },
903 {
904 6, 7, 8, 8, 8, 8, 8, 8
905 },
906 {
907 7, 8, 8, 8, 8, 8, 8, 8
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 8
911 }
912 },
913 {
914 {
915 0, 0, 0, 0, 0, 0, 0, 0
916 },
917 {
918 0, 0, 0, 0, 0, 0, 0, 15
919 },
920 {
921 0, 0, 0, 0, 0, 0, 15, 14
922 },
923 {
924 0, 0, 0, 0, 0, 15, 14, 13
925 },
926 {
927 0, 0, 0, 0, 15, 14, 13, 12
928 },
929 {
930 0, 0, 0, 15, 14, 13, 12, 11
931 },
932 {
933 0, 0, 15, 14, 13, 12, 11, 10
934 },
935 {
936 0, 15, 14, 13, 12, 11, 10, 9
937 },
938 {
939 15, 14, 13, 12, 11, 10, 9, 8
940 },
941 {
942 14, 13, 12, 11, 10, 9, 8, 8
943 },
944 {
945 13, 12, 11, 10, 9, 8, 8, 8
946 },
947 {
948 12, 11, 10, 9, 8, 8, 8, 8
949 },
950 {
951 11, 10, 9, 8, 8, 8, 8, 8
952 },
953 {
954 10, 9, 8, 8, 8, 8, 8, 8
955 },
956 {
957 9, 8, 8, 8, 8, 8, 8, 8
958 },
959 {
960 8, 8, 8, 8, 8, 8, 8, 8
961 }
962 }
963 };
964 */
965
966
967
968 /*
969 for (int32_t blockrow=0; blockrow<30; ++i)
970 {
971 for (int32_t linerow=0; linerow<8; ++i)
972 {
973 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
974 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
975 {
976 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
977 ++triangleline;
978 }
979 }
980 }
981 */
982
983 // the ULL suffixes are to prevent this warning:
984 // warning: integer constant is too large for "int32_t" type
985
986 qword triangles[4][16][8]= //[direction][value][line]
987 {
988 {
989 {
990 0x0000000000000000ULL,
991 0x0000000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL
998 },
999 {
1000 0xFD00000000000000ULL,
1001 0x0000000000000000ULL,
1002 0x0000000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL
1008 },
1009 {
1010 0xFDFD000000000000ULL,
1011 0xFD00000000000000ULL,
1012 0x0000000000000000ULL,
1013 0x0000000000000000ULL,
1014 0x0000000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL
1018 },
1019 {
1020 0xFDFDFD0000000000ULL,
1021 0xFDFD000000000000ULL,
1022 0xFD00000000000000ULL,
1023 0x0000000000000000ULL,
1024 0x0000000000000000ULL,
1025 0x0000000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL
1028 },
1029 {
1030 0xFDFDFDFD00000000ULL,
1031 0xFDFDFD0000000000ULL,
1032 0xFDFD000000000000ULL,
1033 0xFD00000000000000ULL,
1034 0x0000000000000000ULL,
1035 0x0000000000000000ULL,
1036 0x0000000000000000ULL,
1037 0x0000000000000000ULL
1038 },
1039 {
1040 0xFDFDFDFDFD000000ULL,
1041 0xFDFDFDFD00000000ULL,
1042 0xFDFDFD0000000000ULL,
1043 0xFDFD000000000000ULL,
1044 0xFD00000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL
1048 },
1049 {
1050 0xFDFDFDFDFDFD0000ULL,
1051 0xFDFDFDFDFD000000ULL,
1052 0xFDFDFDFD00000000ULL,
1053 0xFDFDFD0000000000ULL,
1054 0xFDFD000000000000ULL,
1055 0xFD00000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL
1058 },
1059 {
1060 0xFDFDFDFDFDFDFD00ULL,
1061 0xFDFDFDFDFDFD0000ULL,
1062 0xFDFDFDFDFD000000ULL,
1063 0xFDFDFDFD00000000ULL,
1064 0xFDFDFD0000000000ULL,
1065 0xFDFD000000000000ULL,
1066 0xFD00000000000000ULL,
1067 0x0000000000000000ULL
1068 },
1069 {
1070 0xFDFDFDFDFDFDFDFDULL,
1071 0xFDFDFDFDFDFDFD00ULL,
1072 0xFDFDFDFDFDFD0000ULL,
1073 0xFDFDFDFDFD000000ULL,
1074 0xFDFDFDFD00000000ULL,
1075 0xFDFDFD0000000000ULL,
1076 0xFDFD000000000000ULL,
1077 0xFD00000000000000ULL
1078 },
1079 {
1080 0xFDFDFDFDFDFDFDFDULL,
1081 0xFDFDFDFDFDFDFDFDULL,
1082 0xFDFDFDFDFDFDFD00ULL,
1083 0xFDFDFDFDFDFD0000ULL,
1084 0xFDFDFDFDFD000000ULL,
1085 0xFDFDFDFD00000000ULL,
1086 0xFDFDFD0000000000ULL,
1087 0xFDFD000000000000ULL
1088 },
1089 {
1090 0xFDFDFDFDFDFDFDFDULL,
1091 0xFDFDFDFDFDFDFDFDULL,
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFD00ULL,
1094 0xFDFDFDFDFDFD0000ULL,
1095 0xFDFDFDFDFD000000ULL,
1096 0xFDFDFDFD00000000ULL,
1097 0xFDFDFD0000000000ULL
1098 },
1099 {
1100 0xFDFDFDFDFDFDFDFDULL,
1101 0xFDFDFDFDFDFDFDFDULL,
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFD00ULL,
1105 0xFDFDFDFDFDFD0000ULL,
1106 0xFDFDFDFDFD000000ULL,
1107 0xFDFDFDFD00000000ULL
1108 },
1109 {
1110 0xFDFDFDFDFDFDFDFDULL,
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFD00ULL,
1116 0xFDFDFDFDFDFD0000ULL,
1117 0xFDFDFDFDFD000000ULL
1118 },
1119 {
1120 0xFDFDFDFDFDFDFDFDULL,
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFD00ULL,
1127 0xFDFDFDFDFDFD0000ULL
1128 },
1129 {
1130 0xFDFDFDFDFDFDFDFDULL,
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFD00ULL
1138 },
1139 {
1140 0xFDFDFDFDFDFDFDFDULL,
1141 0xFDFDFDFDFDFDFDFDULL,
1142 0xFDFDFDFDFDFDFDFDULL,
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFDFDULL
1148 }
1149 },
1150 {
1151 {
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL
1160 },
1161 {
1162 0x00000000000000FDULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL
1170 },
1171 {
1172 0x000000000000FDFDULL,
1173 0x00000000000000FDULL,
1174 0x0000000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL
1180 },
1181 {
1182 0x0000000000FDFDFDULL,
1183 0x000000000000FDFDULL,
1184 0x00000000000000FDULL,
1185 0x0000000000000000ULL,
1186 0x0000000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL
1190 },
1191 {
1192 0x00000000FDFDFDFDULL,
1193 0x0000000000FDFDFDULL,
1194 0x000000000000FDFDULL,
1195 0x00000000000000FDULL,
1196 0x0000000000000000ULL,
1197 0x0000000000000000ULL,
1198 0x0000000000000000ULL,
1199 0x0000000000000000ULL
1200 },
1201 {
1202 0x000000FDFDFDFDFDULL,
1203 0x00000000FDFDFDFDULL,
1204 0x0000000000FDFDFDULL,
1205 0x000000000000FDFDULL,
1206 0x00000000000000FDULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL
1210 },
1211 {
1212 0x0000FDFDFDFDFDFDULL,
1213 0x000000FDFDFDFDFDULL,
1214 0x00000000FDFDFDFDULL,
1215 0x0000000000FDFDFDULL,
1216 0x000000000000FDFDULL,
1217 0x00000000000000FDULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL
1220 },
1221 {
1222 0x00FDFDFDFDFDFDFDULL,
1223 0x0000FDFDFDFDFDFDULL,
1224 0x000000FDFDFDFDFDULL,
1225 0x00000000FDFDFDFDULL,
1226 0x0000000000FDFDFDULL,
1227 0x000000000000FDFDULL,
1228 0x00000000000000FDULL,
1229 0x0000000000000000ULL
1230 },
1231 {
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0x00FDFDFDFDFDFDFDULL,
1234 0x0000FDFDFDFDFDFDULL,
1235 0x000000FDFDFDFDFDULL,
1236 0x00000000FDFDFDFDULL,
1237 0x0000000000FDFDFDULL,
1238 0x000000000000FDFDULL,
1239 0x00000000000000FDULL
1240 },
1241 {
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0x00FDFDFDFDFDFDFDULL,
1245 0x0000FDFDFDFDFDFDULL,
1246 0x000000FDFDFDFDFDULL,
1247 0x00000000FDFDFDFDULL,
1248 0x0000000000FDFDFDULL,
1249 0x000000000000FDFDULL
1250 },
1251 {
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0x00FDFDFDFDFDFDFDULL,
1256 0x0000FDFDFDFDFDFDULL,
1257 0x000000FDFDFDFDFDULL,
1258 0x00000000FDFDFDFDULL,
1259 0x0000000000FDFDFDULL
1260 },
1261 {
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0x00FDFDFDFDFDFDFDULL,
1267 0x0000FDFDFDFDFDFDULL,
1268 0x000000FDFDFDFDFDULL,
1269 0x00000000FDFDFDFDULL
1270 },
1271 {
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0x00FDFDFDFDFDFDFDULL,
1278 0x0000FDFDFDFDFDFDULL,
1279 0x000000FDFDFDFDFDULL
1280 },
1281 {
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0x00FDFDFDFDFDFDFDULL,
1289 0x0000FDFDFDFDFDFDULL
1290 },
1291 {
1292 0xFDFDFDFDFDFDFDFDULL,
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0x00FDFDFDFDFDFDFDULL
1300 },
1301 {
1302 0xFDFDFDFDFDFDFDFDULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL,
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0xFDFDFDFDFDFDFDFDULL,
1309 0xFDFDFDFDFDFDFDFDULL
1310 }
1311 },
1312 {
1313 {
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL
1322 },
1323 {
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0xFD00000000000000ULL
1332 },
1333 {
1334 0x0000000000000000ULL,
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0xFD00000000000000ULL,
1341 0xFDFD000000000000ULL
1342 },
1343 {
1344 0x0000000000000000ULL,
1345 0x0000000000000000ULL,
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0xFD00000000000000ULL,
1350 0xFDFD000000000000ULL,
1351 0xFDFDFD0000000000ULL
1352 },
1353 {
1354 0x0000000000000000ULL,
1355 0x0000000000000000ULL,
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0xFD00000000000000ULL,
1359 0xFDFD000000000000ULL,
1360 0xFDFDFD0000000000ULL,
1361 0xFDFDFDFD00000000ULL
1362 },
1363 {
1364 0x0000000000000000ULL,
1365 0x0000000000000000ULL,
1366 0x0000000000000000ULL,
1367 0xFD00000000000000ULL,
1368 0xFDFD000000000000ULL,
1369 0xFDFDFD0000000000ULL,
1370 0xFDFDFDFD00000000ULL,
1371 0xFDFDFDFDFD000000ULL
1372 },
1373 {
1374 0x0000000000000000ULL,
1375 0x0000000000000000ULL,
1376 0xFD00000000000000ULL,
1377 0xFDFD000000000000ULL,
1378 0xFDFDFD0000000000ULL,
1379 0xFDFDFDFD00000000ULL,
1380 0xFDFDFDFDFD000000ULL,
1381 0xFDFDFDFDFDFD0000ULL
1382 },
1383 {
1384 0x0000000000000000ULL,
1385 0xFD00000000000000ULL,
1386 0xFDFD000000000000ULL,
1387 0xFDFDFD0000000000ULL,
1388 0xFDFDFDFD00000000ULL,
1389 0xFDFDFDFDFD000000ULL,
1390 0xFDFDFDFDFDFD0000ULL,
1391 0xFDFDFDFDFDFDFD00ULL
1392 },
1393 {
1394 0xFD00000000000000ULL,
1395 0xFDFD000000000000ULL,
1396 0xFDFDFD0000000000ULL,
1397 0xFDFDFDFD00000000ULL,
1398 0xFDFDFDFDFD000000ULL,
1399 0xFDFDFDFDFDFD0000ULL,
1400 0xFDFDFDFDFDFDFD00ULL,
1401 0xFDFDFDFDFDFDFDFDULL
1402 },
1403 {
1404 0xFDFD000000000000ULL,
1405 0xFDFDFD0000000000ULL,
1406 0xFDFDFDFD00000000ULL,
1407 0xFDFDFDFDFD000000ULL,
1408 0xFDFDFDFDFDFD0000ULL,
1409 0xFDFDFDFDFDFDFD00ULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL
1412 },
1413 {
1414 0xFDFDFD0000000000ULL,
1415 0xFDFDFDFD00000000ULL,
1416 0xFDFDFDFDFD000000ULL,
1417 0xFDFDFDFDFDFD0000ULL,
1418 0xFDFDFDFDFDFDFD00ULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL
1422 },
1423 {
1424 0xFDFDFDFD00000000ULL,
1425 0xFDFDFDFDFD000000ULL,
1426 0xFDFDFDFDFDFD0000ULL,
1427 0xFDFDFDFDFDFDFD00ULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL
1432 },
1433 {
1434 0xFDFDFDFDFD000000ULL,
1435 0xFDFDFDFDFDFD0000ULL,
1436 0xFDFDFDFDFDFDFD00ULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL
1442 },
1443 {
1444 0xFDFDFDFDFDFD0000ULL,
1445 0xFDFDFDFDFDFDFD00ULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL
1452 },
1453 {
1454 0xFDFDFDFDFDFDFD00ULL,
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL
1462 },
1463 {
1464 0xFDFDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL,
1469 0xFDFDFDFDFDFDFDFDULL,
1470 0xFDFDFDFDFDFDFDFDULL,
1471 0xFDFDFDFDFDFDFDFDULL
1472 }
1473 },
1474 {
1475 {
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL
1484 },
1485 {
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x00000000000000FDULL
1494 },
1495 {
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x00000000000000FDULL,
1503 0x000000000000FDFDULL
1504 },
1505 {
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x00000000000000FDULL,
1512 0x000000000000FDFDULL,
1513 0x0000000000FDFDFDULL
1514 },
1515 {
1516 0x0000000000000000ULL,
1517 0x0000000000000000ULL,
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x00000000000000FDULL,
1521 0x000000000000FDFDULL,
1522 0x0000000000FDFDFDULL,
1523 0x00000000FDFDFDFDULL
1524 },
1525 {
1526 0x0000000000000000ULL,
1527 0x0000000000000000ULL,
1528 0x0000000000000000ULL,
1529 0x00000000000000FDULL,
1530 0x000000000000FDFDULL,
1531 0x0000000000FDFDFDULL,
1532 0x00000000FDFDFDFDULL,
1533 0x000000FDFDFDFDFDULL
1534 },
1535 {
1536 0x0000000000000000ULL,
1537 0x0000000000000000ULL,
1538 0x00000000000000FDULL,
1539 0x000000000000FDFDULL,
1540 0x0000000000FDFDFDULL,
1541 0x00000000FDFDFDFDULL,
1542 0x000000FDFDFDFDFDULL,
1543 0x0000FDFDFDFDFDFDULL
1544 },
1545 {
1546 0x0000000000000000ULL,
1547 0x00000000000000FDULL,
1548 0x000000000000FDFDULL,
1549 0x0000000000FDFDFDULL,
1550 0x00000000FDFDFDFDULL,
1551 0x000000FDFDFDFDFDULL,
1552 0x0000FDFDFDFDFDFDULL,
1553 0x00FDFDFDFDFDFDFDULL
1554 },
1555 {
1556 0x00000000000000FDULL,
1557 0x000000000000FDFDULL,
1558 0x0000000000FDFDFDULL,
1559 0x00000000FDFDFDFDULL,
1560 0x000000FDFDFDFDFDULL,
1561 0x0000FDFDFDFDFDFDULL,
1562 0x00FDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL
1564 },
1565 {
1566 0x000000000000FDFDULL,
1567 0x0000000000FDFDFDULL,
1568 0x00000000FDFDFDFDULL,
1569 0x000000FDFDFDFDFDULL,
1570 0x0000FDFDFDFDFDFDULL,
1571 0x00FDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL
1574 },
1575 {
1576 0x0000000000FDFDFDULL,
1577 0x00000000FDFDFDFDULL,
1578 0x000000FDFDFDFDFDULL,
1579 0x0000FDFDFDFDFDFDULL,
1580 0x00FDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL
1584 },
1585 {
1586 0x00000000FDFDFDFDULL,
1587 0x000000FDFDFDFDFDULL,
1588 0x0000FDFDFDFDFDFDULL,
1589 0x00FDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL
1594 },
1595 {
1596 0x000000FDFDFDFDFDULL,
1597 0x0000FDFDFDFDFDFDULL,
1598 0x00FDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL
1604 },
1605 {
1606 0x0000FDFDFDFDFDFDULL,
1607 0x00FDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL
1614 },
1615 {
1616 0x00FDFDFDFDFDFDFDULL,
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL
1624 },
1625 {
1626 0xFDFDFDFDFDFDFDFDULL,
1627 0xFDFDFDFDFDFDFDFDULL,
1628 0xFDFDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL,
1631 0xFDFDFDFDFDFDFDFDULL,
1632 0xFDFDFDFDFDFDFDFDULL,
1633 0xFDFDFDFDFDFDFDFDULL
1634 }
1635 }
1636 };
1637
1638 int32_t black_opening_count=0;
1639 int32_t black_opening_x,black_opening_y;
1640 int32_t black_opening_shape;
1641
1642 27 int32_t choose_opening_shape()
1643 {
1644 // First, count how many bits are set
1645 27 int32_t numBits=0;
1646 int32_t bitCounter;
1647
1648
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 27 times.
162 for(int32_t i=0; i<bosMAX; i++)
1649 {
1650
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 27 times.
135 if(COOLSCROLL&(1<<i))
1651 27 numBits++;
1652 135 }
1653
1654 // Shouldn't happen...
1655
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(numBits==0)
1656 return bosCIRCLE;
1657
1658 // Pick a bit
1659 27 bitCounter=zc_rand()%numBits+1;
1660
1661
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<bosMAX; i++)
1662 {
1663 // If this bit is set, decrement the bit counter
1664
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 27 times.
32 if(COOLSCROLL&(1<<i))
1665 27 bitCounter--;
1666
1667 // When the counter hits 0, return a value based on
1668 // which bit it stopped on.
1669 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1670
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 5 times.
32 if(bitCounter==0)
1671 27 return i;
1672 5 }
1673
1674 // Shouldn't be necessary, but the compiler might complain, at least
1675 return bosCIRCLE;
1676 27 }
1677
1678 8 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1679 {
1680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1681
1682 8 int32_t w=256, h=224;
1683 8 int32_t blockrows=28, blockcolumns=32;
1684 8 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1685
1686
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 8 times.
232 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1687 {
1688
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 224 times.
7392 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1689 {
1690
2/2
✓ Branch 0 taken 3692 times.
✓ Branch 1 taken 3476 times.
7168 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1691 7168 }
1692 224 }
1693
1694 8 black_opening_count = 66;
1695 8 black_opening_x = x;
1696 8 black_opening_y = y;
1697 8 lensclk = 0;
1698 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1699
1700
1701
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(black_opening_shape == bosFADEBLACK)
1702 {
1703 refreshTints();
1704 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1705 }
1706
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(wait)
1707 {
1708 FFCore.warpScriptCheck();
1709 for(int32_t i=0; i<66; i++)
1710 {
1711 draw_screen(tmpscr);
1712 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1713 syskeys();
1714 advanceframe(true);
1715
1716 if(Quit)
1717 {
1718 break;
1719 }
1720 }
1721 }
1722 8 }
1723
1724 19 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1725 {
1726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1727
1728 19 int32_t w=256, h=224;
1729 19 int32_t blockrows=28, blockcolumns=32;
1730 19 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1731
1732
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 19 times.
551 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1733 {
1734
2/2
✓ Branch 0 taken 17024 times.
✓ Branch 1 taken 532 times.
17556 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1735 {
1736
2/2
✓ Branch 0 taken 8076 times.
✓ Branch 1 taken 8948 times.
17024 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1737 17024 }
1738 532 }
1739
1740 19 black_opening_count = -66;
1741 19 black_opening_x = x;
1742 19 black_opening_y = y;
1743 19 lensclk = 0;
1744
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(black_opening_shape == bosFADEBLACK)
1745 {
1746 refreshTints();
1747 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1748 }
1749
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 13 times.
19 if(wait)
1750 {
1751 13 FFCore.warpScriptCheck();
1752
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 858 times.
871 for(int32_t i=0; i<66; i++)
1753 {
1754 858 draw_screen(tmpscr);
1755 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1756 858 syskeys();
1757 858 advanceframe(true);
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
858 if(Quit)
1760 {
1761 break;
1762 }
1763 858 }
1764 13 }
1765 19 }
1766
1767 1782 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1768 {
1769 1782 clear_to_color(tmp_scr,BLACK);
1770 1782 int32_t w=256, h=224;
1771
1772
3/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1650 times.
1782 switch(black_opening_shape)
1773 {
1774 case bosOVAL:
1775 {
1776 double new_w=(w/2)+abs(w/2-x);
1777 double new_h=(h/2)+abs(h/2-y);
1778 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1779 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1780 break;
1781 }
1782
1783 case bosTRIANGLE:
1784 {
1785 66 double new_w=(w/2)+abs(w/2-x);
1786 66 double new_h=(h/2)+abs(h/2-y);
1787 66 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1788 66 double P2= (PI/2);
1789 66 double P23=(2*PI/3);
1790 66 double P43=(4*PI/3);
1791 66 double Pa= (-4*PI*a/(3*max_a));
1792 66 double angle=P2+Pa;
1793 66 double a0=angle;
1794 66 double a2=angle+P23;
1795 66 double a4=angle+P43;
1796 132 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1797 66 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1798 66 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1799 0);
1800 66 break;
1801 }
1802
1803 case bosSMAS:
1804 {
1805
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1806
1807
2/2
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 66 times.
1914 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1808 {
1809
2/2
✓ Branch 0 taken 14784 times.
✓ Branch 1 taken 1848 times.
16632 for(int32_t linerow=0; linerow<8; ++linerow)
1810 {
1811 14784 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1812
1813
2/2
✓ Branch 0 taken 473088 times.
✓ Branch 1 taken 14784 times.
487872 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1814 {
1815 1419264 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1816
6/6
✓ Branch 0 taken 332640 times.
✓ Branch 1 taken 140448 times.
✓ Branch 2 taken 314688 times.
✓ Branch 3 taken 158400 times.
✓ Branch 4 taken 174240 times.
✓ Branch 5 taken 140448 times.
473088 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1817 473088 [linerow];
1818 473088 ++triangleline;
1819
1820
2/2
✓ Branch 0 taken 413952 times.
✓ Branch 1 taken 59136 times.
473088 if(linerow==0)
1821 {
1822 59136 }
1823 473088 }
1824 14784 }
1825 1848 }
1826
1827 66 break;
1828 }
1829
1830 case bosFADEBLACK:
1831 {
1832 if(black_opening_count<0)
1833 {
1834 black_fade(zc_min(-black_opening_count,63));
1835 }
1836 else if(black_opening_count>0)
1837 {
1838 black_fade(63-zc_max(black_opening_count-3,0));
1839 }
1840 else black_fade(0);
1841 return; //no blitting from tmp_scr!
1842 }
1843
1844 1650 case bosCIRCLE:
1845 default:
1846 {
1847 1650 double new_w=(w/2)+abs(w/2-x);
1848 1650 double new_h=(h/2)+abs(h/2-y);
1849 1650 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1850 //circlefill(tmp_scr,x,y,a<<3,0);
1851 1650 circlefill(tmp_scr,x,y,r,0);
1852 1650 break;
1853 }
1854 }
1855
1856 1782 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1857 1782 }
1858
1859
1860 void black_fade(int32_t fadeamnt)
1861 {
1862 for(int32_t i=0; i < 0xEF; i++)
1863 {
1864 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1865 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1866 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1867 }
1868
1869 refreshpal = true;
1870 }
1871
1872 //----------------------------------------------------------------
1873
1874 19099 bool item_disabled(int32_t item) //is this item disabled?
1875 {
1876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19099 times.
19099 return (item>=0 && game->items_off[item] != 0);
1877 }
1878
1879 85317 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1880 {
1881
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 84517 times.
85317 if(current_item(item_type, true) >=item)
1882 {
1883 800 return true;
1884 }
1885
1886 84517 return false;
1887 85317 }
1888
1889 337986 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1890 {
1891
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 62733 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 27027 times.
✓ Branch 6 taken 192786 times.
✓ Branch 7 taken 54648 times.
✓ Branch 8 taken 792 times.
337986 switch(item_type)
1892 {
1893 case itype_bomb:
1894 case itype_sbomb:
1895 {
1896 int32_t itemid = getItemID(itemsbuf, item_type, it);
1897
1898 if(itemid == -1)
1899 return false;
1900
1901 return (game->get_item(itemid));
1902 }
1903
1904 case itype_clock:
1905 {
1906 62733 int32_t itemid = getItemID(itemsbuf, item_type, it);
1907
1908
2/4
✓ Branch 0 taken 62733 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62733 times.
✗ Branch 3 not taken.
62733 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1909 return (game->get_item(itemid));
1910 62733 return Hero.getClock()?1:0;
1911 }
1912
1913 case itype_key:
1914 return (game->get_keys()>0);
1915
1916 case itype_magiccontainer:
1917 return (game->get_maxmagic()>=game->get_mp_per_block());
1918
1919 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1920 {
1921
1/3
✓ Branch 0 taken 27027 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27027 switch(it)
1922 {
1923 case -2:
1924 {
1925 for(int32_t i=0; i<MAXLEVELS; i++)
1926 {
1927 if(game->lvlitems[i]&liTRIFORCE)
1928 {
1929 return true;
1930 }
1931 }
1932
1933 return false;
1934 }
1935
1936 case -1:
1937 return (game->lvlitems[dlevel]&liTRIFORCE);
1938
1939 default:
1940
2/4
✓ Branch 0 taken 27027 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27027 times.
27027 if(it>=0&&it<MAXLEVELS)
1941 {
1942 27027 return (game->lvlitems[it]&liTRIFORCE);
1943 }
1944
1945 break;
1946 }
1947
1948 return 0;
1949 }
1950
1951 case itype_map: //it: -2=any, -1=current level, other=that level
1952 {
1953
1/3
✓ Branch 0 taken 192786 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
192786 switch(it)
1954 {
1955 case -2:
1956 {
1957 for(int32_t i=0; i<MAXLEVELS; i++)
1958 {
1959 if(game->lvlitems[i]&liMAP)
1960 {
1961 return true;
1962 }
1963 }
1964
1965 return false;
1966 }
1967
1968 case -1:
1969 return (game->lvlitems[dlevel]&liMAP)!=0;
1970
1971 default:
1972
2/4
✓ Branch 0 taken 192786 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192786 times.
192786 if(it>=0&&it<MAXLEVELS)
1973 {
1974 192786 return (game->lvlitems[it]&liMAP)!=0;
1975 }
1976
1977 break;
1978 }
1979
1980 return 0;
1981 }
1982
1983 case itype_compass: //it: -2=any, -1=current level, other=that level
1984 {
1985
1/3
✓ Branch 0 taken 54648 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
54648 switch(it)
1986 {
1987 case -2:
1988 {
1989 for(int32_t i=0; i<MAXLEVELS; i++)
1990 {
1991 if(game->lvlitems[i]&liCOMPASS)
1992 {
1993 return true;
1994 }
1995 }
1996
1997 return false;
1998 }
1999
2000 case -1:
2001 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2002
2003 default:
2004
2/4
✓ Branch 0 taken 54648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54648 times.
✗ Branch 3 not taken.
54648 if(it>=0&&it<MAXLEVELS)
2005 {
2006 54648 return (game->lvlitems[it]&liCOMPASS)!=0;
2007 }
2008
2009 break;
2010 }
2011 return 0;
2012 }
2013
2014 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2015 {
2016
1/3
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
792 switch(it)
2017 {
2018 case -2:
2019 {
2020 for(int32_t i=0; i<MAXLEVELS; i++)
2021 {
2022 if(game->lvlitems[i]&liBOSSKEY)
2023 {
2024 return true;
2025 }
2026 }
2027
2028 return false;
2029 }
2030
2031 case -1:
2032 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2033
2034 default:
2035
2/4
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 792 times.
792 if(it>=0&&it<MAXLEVELS)
2036 {
2037 792 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2038 }
2039 break;
2040 }
2041 return 0;
2042 }
2043
2044 default:
2045 //it=(1<<(it-1));
2046 /*if (item_type>=itype_max)
2047 {
2048 system_pal();
2049 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2050 game_pal();
2051
2052 return false;
2053 }*/
2054 int32_t itemid = getItemID(itemsbuf, item_type, it);
2055
2056 if(itemid == -1)
2057 return false;
2058
2059 return game->get_item(itemid);
2060 }
2061 337986 }
2062
2063
2064 1044825 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2065 {
2066
9/9
✓ Branch 0 taken 62733 times.
✓ Branch 1 taken 542961 times.
✓ Branch 2 taken 62733 times.
✓ Branch 3 taken 62733 times.
✓ Branch 4 taken 62733 times.
✓ Branch 5 taken 62733 times.
✓ Branch 6 taken 62733 times.
✓ Branch 7 taken 62733 times.
✓ Branch 8 taken 62733 times.
1044825 switch(item_type)
2067 {
2068 case itype_clock:
2069 {
2070 62733 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2071
2072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62733 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62733 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2073 return itemsbuf[maxid].fam_type;
2074
2075 62733 return has_item(itype_clock,1) ? 1 : 0;
2076 }
2077
2078 case itype_key:
2079 62733 return game->get_keys();
2080
2081 case itype_lkey:
2082 62733 return game->lvlkeys[get_dlevel()];
2083
2084 case itype_magiccontainer:
2085 62733 return game->get_maxmagic()/game->get_mp_per_block();
2086
2087 case itype_triforcepiece:
2088 {
2089 62733 int32_t count=0;
2090
2091
2/2
✓ Branch 0 taken 32119296 times.
✓ Branch 1 taken 62733 times.
32182029 for(int32_t i=0; i<MAXLEVELS; i++)
2092 {
2093 32119296 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2094 32119296 }
2095
2096 62733 return count;
2097 }
2098
2099 case itype_map:
2100 {
2101 62733 int32_t count=0;
2102
2103
2/2
✓ Branch 0 taken 32119296 times.
✓ Branch 1 taken 62733 times.
32182029 for(int32_t i=0; i<MAXLEVELS; i++)
2104 {
2105 32119296 count+=(game->lvlitems[i]&liMAP)?1:0;
2106 32119296 }
2107
2108 62733 return count;
2109 }
2110
2111 case itype_compass:
2112 {
2113 62733 int32_t count=0;
2114
2115
2/2
✓ Branch 0 taken 32119296 times.
✓ Branch 1 taken 62733 times.
32182029 for(int32_t i=0; i<MAXLEVELS; i++)
2116 {
2117 32119296 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2118 32119296 }
2119
2120 62733 return count;
2121 }
2122
2123 case itype_bosskey:
2124 {
2125 62733 int32_t count=0;
2126
2127
2/2
✓ Branch 0 taken 32119296 times.
✓ Branch 1 taken 62733 times.
32182029 for(int32_t i=0; i<MAXLEVELS; i++)
2128 {
2129 32119296 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2130 32119296 }
2131
2132 62733 return count;
2133 }
2134
2135 default:
2136 542961 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2137
2138
2/2
✓ Branch 0 taken 19574 times.
✓ Branch 1 taken 523387 times.
542961 if(maxid == -1)
2139 523387 return 0;
2140
2141 19574 return itemsbuf[maxid].fam_type;
2142 }
2143 1044825 }
2144
2145 959508 int32_t current_item(int32_t item_type) //item currently being used
2146 {
2147 959508 return current_item(item_type, true);
2148 }
2149
2150 14 std::map<int32_t, int32_t> itemcache;
2151
2152 // Not actually used by anything at the moment...
2153 void removeFromItemCache(int32_t itemid)
2154 {
2155 itemcache.erase(itemid);
2156 }
2157
2158 557 void flushItemCache()
2159 {
2160 557 itemcache.clear();
2161
2162 //also fix the active subscreen if items were deleted -DD
2163
1/2
✓ Branch 0 taken 557 times.
✗ Branch 1 not taken.
557 if(game != NULL)
2164 {
2165 557 verifyBothWeapons();
2166 557 load_Sitems(&QMisc);
2167 557 }
2168 557 }
2169
2170 // This is used often, so it should be as direct as possible.
2171 34822958 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2172 {
2173
2/2
✓ Branch 0 taken 34236453 times.
✓ Branch 1 taken 586505 times.
34822958 if(jinx_check)
2174 {
2175
3/4
✓ Branch 0 taken 439909 times.
✓ Branch 1 taken 146596 times.
✓ Branch 2 taken 439909 times.
✗ Branch 3 not taken.
586505 if(!(HeroSwordClk() || HeroItemClk()))
2176 439909 jinx_check = false; //not jinxed
2177 586505 }
2178
4/4
✓ Branch 0 taken 34566572 times.
✓ Branch 1 taken 256386 times.
✓ Branch 2 taken 146120 times.
✓ Branch 3 taken 34420452 times.
34822958 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2179 {
2180 34420452 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2181
2182
2/2
✓ Branch 0 taken 34136771 times.
✓ Branch 1 taken 283681 times.
34420452 if(res != itemcache.end())
2183 34136771 return res->second;
2184 283681 }
2185
2186 686187 int32_t result = -1;
2187 686187 int32_t highestlevel = -1;
2188
2189
2/2
✓ Branch 0 taken 175663872 times.
✓ Branch 1 taken 686187 times.
176350059 for(int32_t i=0; i<MAXITEMS; i++)
2190 {
2191
5/6
✓ Branch 0 taken 4124670 times.
✓ Branch 1 taken 171539202 times.
✓ Branch 2 taken 17269 times.
✓ Branch 3 taken 4107401 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17269 times.
175663872 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2192 {
2193
4/4
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 10197 times.
✓ Branch 2 taken 4998 times.
✓ Branch 3 taken 12271 times.
17269 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2194 {
2195 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2196
2/2
✓ Branch 0 taken 12203 times.
✓ Branch 1 taken 68 times.
12271 if(!checkmagiccost(i))
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2199 }
2200 12203 }
2201
4/6
✓ Branch 0 taken 14409 times.
✓ Branch 1 taken 2792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2792 times.
✓ Branch 4 taken 2792 times.
✗ Branch 5 not taken.
17201 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2202 {
2203 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2204 continue;
2205 }
2206
2207
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 17135 times.
17201 if(itemsbuf[i].fam_type >= highestlevel)
2208 {
2209 17135 highestlevel = itemsbuf[i].fam_type;
2210 17135 result=i;
2211 17135 }
2212 17201 }
2213 175663804 }
2214
2215
2/2
✓ Branch 0 taken 146596 times.
✓ Branch 1 taken 539591 times.
686187 if(!jinx_check) //Can't cache jinx_check results
2216 539591 itemcache[itemtype] = result;
2217 686187 return result;
2218 34822958 }
2219
2220 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2221 34678062 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2222 {
2223 34678062 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2224
2/2
✓ Branch 0 taken 441609 times.
✓ Branch 1 taken 34236453 times.
34678062 if(!jinx_check) //If not already a jinx-immune-only check...
2225 {
2226 //And the player IS jinxed...
2227
3/4
✓ Branch 0 taken 34091557 times.
✓ Branch 1 taken 144896 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34091557 times.
34236453 if(HeroSwordClk() || HeroItemClk())
2228 {
2229 //Then do a jinx-immune-only check here
2230 144896 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2231 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2232 //Should NOT need a compat rule, as this should always return -1 in old quests.
2233
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 142910 times.
144896 if(ret2 > -1) return ret2;
2234 142910 }
2235 34234467 }
2236 34676076 return ret;
2237 34678062 }
2238 251240 int32_t current_item_power(int32_t itemtype)
2239 {
2240 251240 int32_t result = current_item_id(itemtype,true);
2241
2/2
✓ Branch 0 taken 247196 times.
✓ Branch 1 taken 4044 times.
251240 return (result<0) ? 0 : itemsbuf[result].power;
2242 }
2243
2244 int32_t heart_container_id()
2245 {
2246 for(int32_t i=0; i<MAXITEMS; i++)
2247 {
2248 if(itemsbuf[i].family == itype_heartcontainer)
2249 {
2250 return i;
2251 }
2252 }
2253 return -1;
2254 }
2255
2256 62733 int32_t item_tile_mod()
2257 {
2258 62733 int32_t tile=0;
2259
2260
2/2
✓ Branch 0 taken 58767 times.
✓ Branch 1 taken 3966 times.
62733 if(game->get_bombs())
2261 {
2262 3966 int32_t itemid = current_item_id(itype_bomb,false);
2263
3/4
✓ Branch 0 taken 3444 times.
✓ Branch 1 taken 522 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3444 times.
3966 if(itemid > -1 && checkbunny(itemid))
2264 3444 tile+=itemsbuf[itemid].ltm;
2265 3966 }
2266
2267
2/2
✓ Branch 0 taken 61611 times.
✓ Branch 1 taken 1122 times.
62733 if(game->get_sbombs())
2268 {
2269 1122 int32_t itemid = current_item_id(itype_sbomb,false);
2270
2/4
✓ Branch 0 taken 1122 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1122 times.
1122 if(itemid > -1 && checkbunny(itemid))
2271 1122 tile+=itemsbuf[itemid].ltm;
2272 1122 }
2273
2274
2/2
✓ Branch 0 taken 62256 times.
✓ Branch 1 taken 477 times.
62733 if(current_item(itype_clock))
2275 {
2276 477 int32_t itemid =
2277
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2278 ? iClock
2279 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2280
2/4
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 477 times.
477 if(itemid > -1 && checkbunny(itemid))
2281 477 tile+=itemsbuf[itemid].ltm;
2282 477 }
2283
2284
2/2
✓ Branch 0 taken 58286 times.
✓ Branch 1 taken 4447 times.
62733 if(current_item(itype_key))
2285 {
2286 4447 int32_t itemid =
2287
1/2
✓ Branch 0 taken 4447 times.
✗ Branch 1 not taken.
4447 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2288 ? iKey
2289 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2290
2/4
✓ Branch 0 taken 4447 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4447 times.
4447 if(itemid > -1 && checkbunny(itemid))
2291 4447 tile+=itemsbuf[itemid].ltm;
2292 4447 }
2293
2294
2/2
✓ Branch 0 taken 56210 times.
✓ Branch 1 taken 6523 times.
62733 if(current_item(itype_lkey))
2295 {
2296 6523 int32_t itemid =
2297
1/2
✓ Branch 0 taken 6523 times.
✗ Branch 1 not taken.
6523 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2298 ? iLevelKey
2299 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2300
2/4
✓ Branch 0 taken 6523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6523 times.
6523 if(itemid > -1 && checkbunny(itemid))
2301 6523 tile+=itemsbuf[itemid].ltm;
2302 6523 }
2303
2304
2/2
✓ Branch 0 taken 43121 times.
✓ Branch 1 taken 19612 times.
62733 if(current_item(itype_map))
2305 {
2306 19612 int32_t itemid =
2307
2/2
✓ Branch 0 taken 18826 times.
✓ Branch 1 taken 786 times.
19612 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2308 ? iMap
2309 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2310
2/4
✓ Branch 0 taken 19612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19612 times.
19612 if(itemid > -1 && checkbunny(itemid))
2311 19612 tile+=itemsbuf[itemid].ltm;
2312 19612 }
2313
2314
2/2
✓ Branch 0 taken 39990 times.
✓ Branch 1 taken 22743 times.
62733 if(current_item(itype_compass))
2315 {
2316 22743 int32_t itemid =
2317
2/2
✓ Branch 0 taken 22221 times.
✓ Branch 1 taken 522 times.
22743 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2318 ? iCompass
2319 522 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2320
2/4
✓ Branch 0 taken 22743 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22743 times.
22743 if(itemid > -1 && checkbunny(itemid))
2321 22743 tile+=itemsbuf[itemid].ltm;
2322 22743 }
2323
2324
2/2
✓ Branch 0 taken 52100 times.
✓ Branch 1 taken 10633 times.
62733 if(current_item(itype_bosskey))
2325 {
2326 10633 int32_t itemid =
2327
1/2
✓ Branch 0 taken 10633 times.
✗ Branch 1 not taken.
10633 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2328 ? iBossKey
2329 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2330
2/4
✓ Branch 0 taken 10633 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10633 times.
10633 if(itemid > -1 && checkbunny(itemid))
2331 10633 tile+=itemsbuf[itemid].ltm;
2332 10633 }
2333
2334
2/2
✓ Branch 0 taken 61425 times.
✓ Branch 1 taken 1308 times.
62733 if(current_item(itype_magiccontainer))
2335 {
2336 1308 int32_t itemid =
2337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1308 times.
1308 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2338 ? iMagicC
2339 1308 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2340
2/4
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1308 times.
1308 if(itemid > -1 && checkbunny(itemid))
2341 1308 tile+=itemsbuf[itemid].ltm;
2342 1308 }
2343
2344
2/2
✓ Branch 0 taken 57580 times.
✓ Branch 1 taken 5153 times.
62733 if(current_item(itype_triforcepiece))
2345 {
2346 5153 int32_t itemid =
2347
1/2
✓ Branch 0 taken 5153 times.
✗ Branch 1 not taken.
5153 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2348 ? iTriforce
2349 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2350
2/4
✓ Branch 0 taken 5153 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5153 times.
5153 if(itemid > -1 && checkbunny(itemid))
2351 5153 tile+=itemsbuf[itemid].ltm;
2352 5153 }
2353
2354
2/2
✓ Branch 0 taken 62733 times.
✓ Branch 1 taken 32119296 times.
32182029 for(int32_t i=0; i<itype_max; i++)
2355 {
2356
2/2
✓ Branch 0 taken 24069120 times.
✓ Branch 1 taken 8050176 times.
32119296 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2357 {
2358
2/2
✓ Branch 0 taken 157230 times.
✓ Branch 1 taken 7892946 times.
8050176 switch(i)
2359 {
2360 case itype_bomb:
2361 case itype_sbomb:
2362 case itype_clock:
2363 case itype_key:
2364 case itype_lkey:
2365 case itype_map:
2366 case itype_compass:
2367 case itype_bosskey:
2368 case itype_magiccontainer:
2369 case itype_triforcepiece:
2370 157230 continue; //already handled
2371 }
2372 7892946 }
2373 31962066 int32_t itemid = current_item_id(i,false);
2374
2/2
✓ Branch 0 taken 31899333 times.
✓ Branch 1 taken 62733 times.
31962066 if(i == itype_shield)
2375 62733 itemid = getCurrentShield(false);
2376
2377
3/4
✓ Branch 0 taken 227501 times.
✓ Branch 1 taken 31734565 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 227501 times.
31962066 if(itemid < 0 || !checkbunny(itemid))
2378 31734565 continue;
2379
2380 227501 itemdata const& itm = itemsbuf[itemid];
2381
2382
2/2
✓ Branch 0 taken 165290 times.
✓ Branch 1 taken 62211 times.
227501 switch(itm.family)
2383 {
2384 case itype_shield:
2385
1/2
✓ Branch 0 taken 62211 times.
✗ Branch 1 not taken.
62211 if(itm.flags & ITEM_FLAG9) //active shield
2386 {
2387 if(!usingActiveShield(itemid))
2388 {
2389 tile+=itm.misc6; //'Inactive PTM'
2390 continue;
2391 }
2392 }
2393 62211 break;
2394 }
2395
2396 227501 tile+=itm.ltm;
2397 227501 }
2398
2399 62733 return tile;
2400 }
2401
2402 62733 int32_t bunny_tile_mod()
2403 {
2404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62733 times.
62733 if(Hero.BunnyClock())
2405 {
2406 return game->get_bunny_ltm();
2407 }
2408 62733 return 0;
2409 62733 }
2410
2411 // Hints are drawn on a separate layer to combo reveals.
2412 void draw_lens_under(BITMAP *dest, bool layer)
2413 {
2414 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2415 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2416 //Lens flag 3: Don't show armos/chest/dive items
2417 //Lens flag 4: Show Raft Paths
2418 //Lens flag 5: Show Invisible Enemies
2419 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2420
2421 int32_t strike_hint_table[11]=
2422 {
2423 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2424 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2425 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2426 };
2427
2428 // int32_t page = tmpscr->cpage;
2429 {
2430 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2431 // int32_t temptimer=0;
2432 int32_t tempitem, tempweapon=0;
2433 strike_hint=strike_hint_table[strike_hint_counter];
2434
2435 if(strike_hint_timer>32)
2436 {
2437 strike_hint_timer=0;
2438 strike_hint_counter=((strike_hint_counter+1)%11);
2439 }
2440
2441 ++strike_hint_timer;
2442
2443 for(int32_t i=0; i<176; i++)
2444 {
2445 int32_t x = (i & 15) << 4;
2446 int32_t y = (i & 0xF0) + playing_field_offset;
2447 int32_t tempitemx=-16, tempitemy=-16;
2448 int32_t tempweaponx=-16, tempweapony=-16;
2449
2450 for(int32_t iter=0; iter<2; ++iter)
2451 {
2452 int32_t checkflag=0;
2453
2454 if(iter==0)
2455 {
2456 checkflag=combobuf[tmpscr->data[i]].flag;
2457 }
2458 else
2459 {
2460 checkflag=tmpscr->sflag[i];
2461 }
2462
2463 if(checkflag==mfSTRIKE)
2464 {
2465 if(!hints)
2466 {
2467 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2468 }
2469 else
2470 {
2471 checkflag = strike_hint;
2472 }
2473 }
2474
2475 switch(checkflag)
2476 {
2477 case 0:
2478 case mfZELDA:
2479 case mfPUSHED:
2480 case mfENEMY0:
2481 case mfENEMY1:
2482 case mfENEMY2:
2483 case mfENEMY3:
2484 case mfENEMY4:
2485 case mfENEMY5:
2486 case mfENEMY6:
2487 case mfENEMY7:
2488 case mfENEMY8:
2489 case mfENEMY9:
2490 case mfSINGLE:
2491 case mfSINGLE16:
2492 case mfNOENEMY:
2493 case mfTRAP_H:
2494 case mfTRAP_V:
2495 case mfTRAP_4:
2496 case mfTRAP_LR:
2497 case mfTRAP_UD:
2498 case mfNOGROUNDENEMY:
2499 case mfNOBLOCKS:
2500 case mfSCRIPT1:
2501 case mfSCRIPT2:
2502 case mfSCRIPT3:
2503 case mfSCRIPT4:
2504 case mfSCRIPT5:
2505 case mfSCRIPT6:
2506 case mfSCRIPT7:
2507 case mfSCRIPT8:
2508 case mfSCRIPT9:
2509 case mfSCRIPT10:
2510 case mfSCRIPT11:
2511 case mfSCRIPT12:
2512 case mfSCRIPT13:
2513 case mfSCRIPT14:
2514 case mfSCRIPT15:
2515 case mfSCRIPT16:
2516 case mfSCRIPT17:
2517 case mfSCRIPT18:
2518 case mfSCRIPT19:
2519 case mfSCRIPT20:
2520 case mfPITHOLE:
2521 case mfPITFALLFLOOR:
2522 case mfLAVA:
2523 case mfICE:
2524 case mfICEDAMAGE:
2525 case mfDAMAGE1:
2526 case mfDAMAGE2:
2527 case mfDAMAGE4:
2528 case mfDAMAGE8:
2529 case mfDAMAGE16:
2530 case mfDAMAGE32:
2531 case mfFREEZEALL:
2532 case mfFREZEALLANSFFCS:
2533 case mfFREEZEFFCSOLY:
2534 case mfSCRITPTW1TRIG:
2535 case mfSCRITPTW2TRIG:
2536 case mfSCRITPTW3TRIG:
2537 case mfSCRITPTW4TRIG:
2538 case mfSCRITPTW5TRIG:
2539 case mfSCRITPTW6TRIG:
2540 case mfSCRITPTW7TRIG:
2541 case mfSCRITPTW8TRIG:
2542 case mfSCRITPTW9TRIG:
2543 case mfSCRITPTW10TRIG:
2544 case mfTROWEL:
2545 case mfTROWELNEXT:
2546 case mfTROWELSPECIALITEM:
2547 case mfSLASHPOT:
2548 case mfLIFTPOT:
2549 case mfLIFTORSLASH:
2550 case mfLIFTROCK:
2551 case mfLIFTROCKHEAVY:
2552 case mfDROPITEM:
2553 case mfSPECIALITEM:
2554 case mfDROPKEY:
2555 case mfDROPLKEY:
2556 case mfDROPCOMPASS:
2557 case mfDROPMAP:
2558 case mfDROPBOSSKEY:
2559 case mfSPAWNNPC:
2560 case mfSWITCHHOOK:
2561 case mfSIDEVIEWLADDER:
2562 case mfSIDEVIEWPLATFORM:
2563 case mfNOENEMYSPAWN:
2564 case mfENEMYALL:
2565 case mfNOMIRROR:
2566 case mfUNSAFEGROUND:
2567 case mf168:
2568 case mf169:
2569 case mf170:
2570 case mf171:
2571 case mf172:
2572 case mf173:
2573 case mf174:
2574 case mf175:
2575 case mf176:
2576 case mf177:
2577 case mf178:
2578 case mf179:
2579 case mf180:
2580 case mf181:
2581 case mf182:
2582 case mf183:
2583 case mf184:
2584 case mf185:
2585 case mf186:
2586 case mf187:
2587 case mf188:
2588 case mf189:
2589 case mf190:
2590 case mf191:
2591 case mf192:
2592 case mf193:
2593 case mf194:
2594 case mf195:
2595 case mf196:
2596 case mf197:
2597 case mf198:
2598 case mf199:
2599 case mf200:
2600 case mf201:
2601 case mf202:
2602 case mf203:
2603 case mf204:
2604 case mf205:
2605 case mf206:
2606 case mf207:
2607 case mf208:
2608 case mf209:
2609 case mf210:
2610 case mf211:
2611 case mf212:
2612 case mf213:
2613 case mf214:
2614 case mf215:
2615 case mf216:
2616 case mf217:
2617 case mf218:
2618 case mf219:
2619 case mf220:
2620 case mf221:
2621 case mf222:
2622 case mf223:
2623 case mf224:
2624 case mf225:
2625 case mf226:
2626 case mf227:
2627 case mf228:
2628 case mf229:
2629 case mf230:
2630 case mf231:
2631 case mf232:
2632 case mf233:
2633 case mf234:
2634 case mf235:
2635 case mf236:
2636 case mf237:
2637 case mf238:
2638 case mf239:
2639 case mf240:
2640 case mf241:
2641 case mf242:
2642 case mf243:
2643 case mf244:
2644 case mf245:
2645 case mf246:
2646 case mf247:
2647 case mf248:
2648 case mf249:
2649 case mf250:
2650 case mf251:
2651 case mf252:
2652 case mf253:
2653 case mf254:
2654 case mfEXTENDED:
2655 break;
2656
2657 case mfPUSHUD:
2658 case mfPUSHLR:
2659 case mfPUSH4:
2660 case mfPUSHU:
2661 case mfPUSHD:
2662 case mfPUSHL:
2663 case mfPUSHR:
2664 case mfPUSHUDNS:
2665 case mfPUSHLRNS:
2666 case mfPUSH4NS:
2667 case mfPUSHUNS:
2668 case mfPUSHDNS:
2669 case mfPUSHLNS:
2670 case mfPUSHRNS:
2671 case mfPUSHUDINS:
2672 case mfPUSHLRINS:
2673 case mfPUSH4INS:
2674 case mfPUSHUINS:
2675 case mfPUSHDINS:
2676 case mfPUSHLINS:
2677 case mfPUSHRINS:
2678 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2679 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2680 {
2681 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2682 }
2683
2684 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2685 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2686 {
2687 if(hints)
2688 {
2689 switch(combobuf[tmpscr->data[i]].type)
2690 {
2691 case cPUSH_HEAVY:
2692 case cPUSH_HW:
2693 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2694 tempitemx=x, tempitemy=y;
2695
2696 if(tempitem>-1)
2697 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2698
2699 break;
2700
2701 case cPUSH_HEAVY2:
2702 case cPUSH_HW2:
2703 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2704 tempitemx=x, tempitemy=y;
2705
2706 if(tempitem>-1)
2707 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2708
2709 break;
2710 }
2711 }
2712 }
2713
2714 break;
2715
2716 case mfWHISTLE:
2717 if(hints)
2718 {
2719 tempitem=getItemID(itemsbuf,itype_whistle,1);
2720
2721 if(tempitem<0) break;
2722
2723 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2724 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2725 {
2726 tempitemx=x;
2727 tempitemy=y;
2728 }
2729
2730 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2731 }
2732
2733 break;
2734
2735 //Why is this here?
2736 case mfFAIRY:
2737 case mfMAGICFAIRY:
2738 case mfALLFAIRY:
2739 if(hints)
2740 {
2741 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2742
2743 if(tempitem < 0) break;
2744
2745 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2746 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2747 {
2748 tempitemx=x;
2749 tempitemy=y;
2750 }
2751
2752 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2753 }
2754
2755 break;
2756
2757 case mfBCANDLE:
2758 if(!hints)
2759 {
2760 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2761 }
2762 else
2763 {
2764 tempitem=getItemID(itemsbuf,itype_candle,1);
2765
2766 if(tempitem<0) break;
2767
2768 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2769 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2770 {
2771 tempitemx=x;
2772 tempitemy=y;
2773 }
2774
2775 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2776 }
2777
2778 break;
2779
2780 case mfRCANDLE:
2781 if(!hints)
2782 {
2783 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2784 }
2785 else
2786 {
2787 tempitem=getItemID(itemsbuf,itype_candle,2);
2788
2789 if(tempitem<0) break;
2790
2791 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2792 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2793 {
2794 tempitemx=x;
2795 tempitemy=y;
2796 }
2797
2798 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2799 }
2800
2801 break;
2802
2803 case mfWANDFIRE:
2804 if(!hints)
2805 {
2806 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2807 }
2808 else
2809 {
2810 tempitem=getItemID(itemsbuf,itype_wand,1);
2811
2812 if(tempitem<0) break;
2813
2814 tempweapon=wFire;
2815
2816 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2817 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2818 {
2819 tempitemx=x;
2820 tempitemy=y;
2821 }
2822 else
2823 {
2824 tempweaponx=x;
2825 tempweapony=y;
2826 }
2827
2828 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfDINSFIRE:
2835 if(!hints)
2836 {
2837 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2838 }
2839 else
2840 {
2841 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2842
2843 if(tempitem<0) break;
2844
2845 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 tempitemx=x;
2849 tempitemy=y;
2850 }
2851
2852 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 break;
2856
2857 case mfARROW:
2858 if(!hints)
2859 {
2860 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2861 }
2862 else
2863 {
2864 tempitem=getItemID(itemsbuf,itype_arrow,1);
2865
2866 if(tempitem<0) break;
2867
2868 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 tempitemx=x;
2872 tempitemy=y;
2873 }
2874
2875 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 break;
2879
2880 case mfSARROW:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_arrow,2);
2888
2889 if(tempitem<0) break;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897
2898 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2899 }
2900
2901 break;
2902
2903 case mfGARROW:
2904 if(!hints)
2905 {
2906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2907 }
2908 else
2909 {
2910 tempitem=getItemID(itemsbuf,itype_arrow,3);
2911
2912 if(tempitem<0) break;
2913
2914 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2915 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2916 {
2917 tempitemx=x;
2918 tempitemy=y;
2919 }
2920
2921 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2922 }
2923
2924 break;
2925
2926 case mfBOMB:
2927 if(!hints)
2928 {
2929 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2930 }
2931 else
2932 {
2933 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2934 tempweapon = wLitBomb;
2935
2936 //if (tempitem<0) break;
2937 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2938 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2939 {
2940 tempweaponx=x;
2941 tempweapony=y;
2942 }
2943
2944 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2945 }
2946
2947 break;
2948
2949 case mfSBOMB:
2950 if(!hints)
2951 {
2952 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2953 }
2954 else
2955 {
2956 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2957 //if (tempitem<0) break;
2958 tempweapon = wLitSBomb;
2959
2960 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2961 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2962 {
2963 tempweaponx=x;
2964 tempweapony=y;
2965 }
2966
2967 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2968 }
2969
2970 break;
2971
2972 case mfARMOS_SECRET:
2973 if(!hints)
2974 {
2975 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2976 }
2977 break;
2978
2979 case mfBRANG:
2980 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2983 }
2984 else
2985 {
2986 tempitem=getItemID(itemsbuf,itype_brang,1);
2987
2988 if(tempitem<0) break;
2989
2990 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 tempitemx=x;
2994 tempitemy=y;
2995 }
2996
2997 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2998 }
2999
3000 break;
3001
3002 case mfMBRANG:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3006 }
3007 else
3008 {
3009 tempitem=getItemID(itemsbuf,itype_brang,2);
3010
3011 if(tempitem<0) break;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempitemx=x;
3017 tempitemy=y;
3018 }
3019
3020 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3021 }
3022
3023 break;
3024
3025 case mfFBRANG:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3029 }
3030 else
3031 {
3032 tempitem=getItemID(itemsbuf,itype_brang,3);
3033
3034 if(tempitem<0) break;
3035
3036 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3037 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3038 {
3039 tempitemx=x;
3040 tempitemy=y;
3041 }
3042
3043 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3044 }
3045
3046 break;
3047
3048 case mfWANDMAGIC:
3049 if(!hints)
3050 {
3051 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3052 }
3053 else
3054 {
3055 tempitem=getItemID(itemsbuf,itype_wand,1);
3056
3057 if(tempitem<0) break;
3058
3059 tempweapon=itemsbuf[tempitem].wpn3;
3060
3061 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3062 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3063 {
3064 tempitemx=x;
3065 tempitemy=y;
3066 }
3067 else
3068 {
3069 tempweaponx=x;
3070 tempweapony=y;
3071 --lens_hint_weapon[wMagic][4];
3072
3073 if(lens_hint_weapon[wMagic][4]<-8)
3074 {
3075 lens_hint_weapon[wMagic][4]=8;
3076 }
3077 }
3078
3079 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3080 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3081 }
3082
3083 break;
3084
3085 case mfREFMAGIC:
3086 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3089 }
3090 else
3091 {
3092 tempitem=getItemID(itemsbuf,itype_shield,3);
3093
3094 if(tempitem<0) break;
3095
3096 tempweapon=ewMagic;
3097
3098 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3099 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3100 {
3101 tempitemx=x;
3102 tempitemy=y;
3103 }
3104 else
3105 {
3106 tempweaponx=x;
3107 tempweapony=y;
3108
3109 if(lens_hint_weapon[ewMagic][2]==up)
3110 {
3111 --lens_hint_weapon[ewMagic][4];
3112 }
3113 else
3114 {
3115 ++lens_hint_weapon[ewMagic][4];
3116 }
3117
3118 if(lens_hint_weapon[ewMagic][4]>8)
3119 {
3120 lens_hint_weapon[ewMagic][2]=up;
3121 }
3122
3123 if(lens_hint_weapon[ewMagic][4]<=0)
3124 {
3125 lens_hint_weapon[ewMagic][2]=down;
3126 }
3127 }
3128
3129 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3130 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3131 }
3132
3133 break;
3134
3135 case mfREFFIREBALL:
3136 if(!hints)
3137 {
3138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3139 }
3140 else
3141 {
3142 tempitem=getItemID(itemsbuf,itype_shield,3);
3143
3144 if(tempitem<0) break;
3145
3146 tempweapon=ewFireball;
3147
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3149 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3150 {
3151 tempitemx=x;
3152 tempitemy=y;
3153 tempweaponx=x;
3154 tempweapony=y;
3155 ++lens_hint_weapon[ewFireball][3];
3156
3157 if(lens_hint_weapon[ewFireball][3]>8)
3158 {
3159 lens_hint_weapon[ewFireball][3]=-8;
3160 lens_hint_weapon[ewFireball][4]=8;
3161 }
3162
3163 if(lens_hint_weapon[ewFireball][3]>0)
3164 {
3165 ++lens_hint_weapon[ewFireball][4];
3166 }
3167 else
3168 {
3169 --lens_hint_weapon[ewFireball][4];
3170 }
3171 }
3172
3173 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3174 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3175 }
3176
3177 break;
3178
3179 case mfSWORD:
3180 if(!hints)
3181 {
3182 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3183 }
3184 else
3185 {
3186 tempitem=getItemID(itemsbuf,itype_sword,1);
3187
3188 if(tempitem<0) break;
3189
3190 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3191 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3192 {
3193 tempitemx=x;
3194 tempitemy=y;
3195 }
3196
3197 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3198 }
3199
3200 break;
3201
3202 case mfWSWORD:
3203 if(!hints)
3204 {
3205 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3206 }
3207 else
3208 {
3209 tempitem=getItemID(itemsbuf,itype_sword,2);
3210
3211 if(tempitem<0) break;
3212
3213 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3214 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3215 {
3216 tempitemx=x;
3217 tempitemy=y;
3218 }
3219
3220 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3221 }
3222
3223 break;
3224
3225 case mfMSWORD:
3226 if(!hints)
3227 {
3228 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3229 }
3230 else
3231 {
3232 tempitem=getItemID(itemsbuf,itype_sword,3);
3233
3234 if(tempitem<0) break;
3235
3236 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3237 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3238 {
3239 tempitemx=x;
3240 tempitemy=y;
3241 }
3242
3243 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3244 }
3245
3246 break;
3247
3248 case mfXSWORD:
3249 if(!hints)
3250 {
3251 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3252 }
3253 else
3254 {
3255 tempitem=getItemID(itemsbuf,itype_sword,4);
3256
3257 if(tempitem<0) break;
3258
3259 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3260 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3261 {
3262 tempitemx=x;
3263 tempitemy=y;
3264 }
3265
3266 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3267 }
3268
3269 break;
3270
3271 case mfSWORDBEAM:
3272 if(!hints)
3273 {
3274 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3275 }
3276 else
3277 {
3278 tempitem=getItemID(itemsbuf,itype_sword,1);
3279
3280 if(tempitem<0) break;
3281
3282 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3283 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3284 {
3285 tempitemx=x;
3286 tempitemy=y;
3287 }
3288
3289 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3290 }
3291
3292 break;
3293
3294 case mfWSWORDBEAM:
3295 if(!hints)
3296 {
3297 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3298 }
3299 else
3300 {
3301 tempitem=getItemID(itemsbuf,itype_sword,2);
3302
3303 if(tempitem<0) break;
3304
3305 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3306 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3307 {
3308 tempitemx=x;
3309 tempitemy=y;
3310 }
3311
3312 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3313 }
3314
3315 break;
3316
3317 case mfMSWORDBEAM:
3318 if(!hints)
3319 {
3320 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3321 }
3322 else
3323 {
3324 tempitem=getItemID(itemsbuf,itype_sword,3);
3325
3326 if(tempitem<0) break;
3327
3328 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3329 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3330 {
3331 tempitemx=x;
3332 tempitemy=y;
3333 }
3334
3335 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3336 }
3337
3338 break;
3339
3340 case mfXSWORDBEAM:
3341 if(!hints)
3342 {
3343 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3344 }
3345 else
3346 {
3347 tempitem=getItemID(itemsbuf,itype_sword,4);
3348
3349 if(tempitem<0) break;
3350
3351 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3352 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3353 {
3354 tempitemx=x;
3355 tempitemy=y;
3356 }
3357
3358 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3359 }
3360
3361 break;
3362
3363 case mfHOOKSHOT:
3364 if(!hints)
3365 {
3366 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3367 }
3368 else
3369 {
3370 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3371
3372 if(tempitem<0) break;
3373
3374 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3375 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3376 {
3377 tempitemx=x;
3378 tempitemy=y;
3379 }
3380
3381 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3382 }
3383
3384 break;
3385
3386 case mfWAND:
3387 if(!hints)
3388 {
3389 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3390 }
3391 else
3392 {
3393 tempitem=getItemID(itemsbuf,itype_wand,1);
3394
3395 if(tempitem<0) break;
3396
3397 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3398 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3399 {
3400 tempitemx=x;
3401 tempitemy=y;
3402 }
3403
3404 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3405 }
3406
3407 break;
3408
3409 case mfHAMMER:
3410 if(!hints)
3411 {
3412 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3413 }
3414 else
3415 {
3416 tempitem=getItemID(itemsbuf,itype_hammer,1);
3417
3418 if(tempitem<0) break;
3419
3420 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3421 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3422 {
3423 tempitemx=x;
3424 tempitemy=y;
3425 }
3426
3427 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3428 }
3429
3430 break;
3431
3432 case mfARMOS_ITEM:
3433 case mfDIVE_ITEM:
3434 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3435 {
3436 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3437 }
3438 break;
3439
3440 case 16:
3441 case 17:
3442 case 18:
3443 case 19:
3444 case 20:
3445 case 21:
3446 case 22:
3447 case 23:
3448 case 24:
3449 case 25:
3450 case 26:
3451 case 27:
3452 case 28:
3453 case 29:
3454 case 30:
3455 case 31:
3456 if(!hints)
3457 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3458 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3459
3460 break;
3461 case mfSECRETSNEXT:
3462 if(!hints)
3463 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3464 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3465
3466 break;
3467
3468 case mfSTRIKE:
3469 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3470 {
3471 goto special;
3472 }
3473 else
3474 {
3475 break;
3476 }
3477
3478 default: goto special;
3479
3480 special:
3481 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3482 {
3483 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3484 {
3485 rectfill(dest,x,y,x+15,y+15,WHITE);
3486 }
3487 }
3488
3489 break;
3490 }
3491 }
3492 }
3493
3494 if(layer)
3495 {
3496 if(tmpscr->door[0]==dWALK)
3497 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3498
3499 if(tmpscr->door[1]==dWALK)
3500 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3501
3502 if(tmpscr->door[2]==dWALK)
3503 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3504
3505 if(tmpscr->door[3]==dWALK)
3506 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3507
3508 if(tmpscr->door[0]==dBOMB)
3509 {
3510 showbombeddoor(dest, 0);
3511 }
3512
3513 if(tmpscr->door[1]==dBOMB)
3514 {
3515 showbombeddoor(dest, 1);
3516 }
3517
3518 if(tmpscr->door[2]==dBOMB)
3519 {
3520 showbombeddoor(dest, 2);
3521 }
3522
3523 if(tmpscr->door[3]==dBOMB)
3524 {
3525 showbombeddoor(dest, 3);
3526 }
3527 }
3528
3529 if(tmpscr->stairx + tmpscr->stairy)
3530 {
3531 if(!hints)
3532 {
3533 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3534 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3535 }
3536 else
3537 {
3538 if(tmpscr->flags&fWHISTLE)
3539 {
3540 tempitem=getItemID(itemsbuf,itype_whistle,1);
3541 int32_t tempitemx=-16;
3542 int32_t tempitemy=-16;
3543
3544 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3545 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3546 {
3547 tempitemx=tmpscr->stairx;
3548 tempitemy=tmpscr->stairy+playing_field_offset;
3549 }
3550
3551 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3552 }
3553 }
3554 }
3555 }
3556 }
3557
3558 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3559
3560 void draw_lens_over()
3561 {
3562 // Oh, what the heck.
3563 static BITMAP *lens_scr = NULL;
3564 static int32_t last_width = -1;
3565 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3566
3567 // Only redraw the circle if the size has changed
3568 if(width != last_width)
3569 {
3570 if(lens_scr == NULL)
3571 {
3572 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3573 }
3574
3575 clear_to_color(lens_scr, BLACK);
3576 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3577 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3578 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3579 last_width=width;
3580 }
3581
3582 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3583 }
3584
3585 //----------------------------------------------------------------
3586
3587 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3588 {
3589 //recreating a big bitmap every frame is highly sluggish.
3590 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3591 clear_to_color(wavebuf, BLACK);
3592 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3593
3594 int32_t ofs;
3595 // int32_t amplitude=8;
3596 // int32_t wavelength=4;
3597 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3598 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3599 int32_t amp2=168;
3600 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3601 int32_t i=frame%amp2;
3602
3603 for(int32_t j=0; j<168; j++)
3604 {
3605 if(j&1 && interpol)
3606 {
3607 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3608 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3609 }
3610 else
3611 {
3612 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3613 }
3614
3615 if(ofs)
3616 {
3617 for(int32_t k=0; k<256; k++)
3618 {
3619 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3620 }
3621 }
3622 }
3623 }
3624
3625 void draw_fuzzy(int32_t fuzz)
3626 // draws from right half of scrollbuf to framebuf
3627 {
3628 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3629 byte *start, *si, *di;
3630
3631 if(fuzz<1)
3632 fuzz = 1;
3633
3634 xstep = 128%fuzz;
3635
3636 if(xstep > 0)
3637 xstep = fuzz-xstep;
3638
3639 ystep = 112%fuzz;
3640
3641 if(ystep > 0)
3642 ystep = fuzz-ystep;
3643
3644 firsty = 1;
3645
3646 for(y=0; y<224;)
3647 {
3648 start = &(scrollbuf->line[y][256]);
3649
3650 for(dy=0; dy<ystep && dy+y<224; dy++)
3651 {
3652 si = start;
3653 di = &(framebuf->line[y+dy][0]);
3654 i = xstep;
3655 firstx = 1;
3656
3657 for(dx=0; dx<256; dx++)
3658 {
3659 *(di++) = *si;
3660
3661 if(++i >= fuzz)
3662 {
3663 if(!firstx)
3664 si += fuzz;
3665 else
3666 {
3667 si += fuzz-xstep;
3668 firstx = 0;
3669 }
3670
3671 i = 0;
3672 }
3673 }
3674 }
3675
3676 if(!firsty)
3677 y += fuzz;
3678 else
3679 {
3680 y += ystep;
3681 ystep = fuzz;
3682 firsty = 0;
3683 }
3684 }
3685 }
3686
3687 120195 void updatescr(bool allowwavy)
3688 {
3689
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 120181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
120195 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3690
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 120181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
120195 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3691
3692
1/2
✓ Branch 0 taken 120195 times.
✗ Branch 1 not taken.
120195 if(toogam)
3693 {
3694 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3695 }
3696
3697
1/2
✓ Branch 0 taken 120195 times.
✗ Branch 1 not taken.
120195 if(Showpal)
3698 dump_pal(framebuf);
3699
3700
2/2
✓ Branch 0 taken 100117 times.
✓ Branch 1 taken 20078 times.
120195 if(!Playing)
3701 20078 black_opening_count=0;
3702
3703
2/2
✓ Branch 0 taken 118941 times.
✓ Branch 1 taken 1254 times.
120195 if(black_opening_count<0) //shape is opening up
3704 {
3705 1254 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3706
3707
2/4
✓ Branch 0 taken 1254 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1254 times.
1254 if(Advance||(!Paused))
3708 {
3709 1254 ++black_opening_count;
3710 1254 }
3711 1254 }
3712
2/2
✓ Branch 0 taken 118413 times.
✓ Branch 1 taken 528 times.
118941 else if(black_opening_count>0) //shape is closing
3713 {
3714 528 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3715
3716
2/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
528 if(Advance||(!Paused))
3717 {
3718 528 --black_opening_count;
3719 528 }
3720 528 }
3721
3722
3/4
✓ Branch 0 taken 118440 times.
✓ Branch 1 taken 1755 times.
✓ Branch 2 taken 118440 times.
✗ Branch 3 not taken.
120195 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3723 {
3724 black_opening_shape = bosCIRCLE;
3725 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3726 refreshTints();
3727 refreshpal=true;
3728 }
3729
3730
2/2
✓ Branch 0 taken 119942 times.
✓ Branch 1 taken 253 times.
120195 if(refreshpal)
3731 {
3732 253 refreshpal=false;
3733 253 RAMpal[253] = _RGB(0,0,0);
3734 253 RAMpal[254] = _RGB(63,63,63);
3735 253 hw_palette = &RAMpal;
3736 253 update_hw_pal = true;
3737
3738 253 create_rgb_table(&rgb_table, RAMpal, NULL);
3739 253 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3740 253 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3741
3742
2/2
✓ Branch 0 taken 64768 times.
✓ Branch 1 taken 253 times.
65021 for(int32_t q=0; q<PAL_SIZE; q++)
3743 {
3744 64768 trans_table2.data[0][q] = q;
3745 64768 trans_table2.data[q][q] = q;
3746 64768 }
3747 253 }
3748
3749 120195 bool clearwavy = (wavy <= 0);
3750
3751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120195 times.
120195 if(wavy <= 0)
3752 {
3753 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3754 120195 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3755 120195 }
3756
3757 120195 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3758
3759
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 120195 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120195 if(wavy && Playing && allowwavy)
3760 {
3761 draw_wavy(framebuf, wavybuf, wavy,false);
3762 }
3763
3764
1/2
✓ Branch 0 taken 120195 times.
✗ Branch 1 not taken.
120195 if(clearwavy)
3765 120195 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3766 else if(Playing && !Paused)
3767 wavy--; // Wavy was set by a script. Decrement it.
3768
3769
5/6
✓ Branch 0 taken 100117 times.
✓ Branch 1 taken 20078 times.
✓ Branch 2 taken 4276 times.
✓ Branch 3 taken 95841 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4276 times.
120195 if(Playing && msgpos && !screenscrolling)
3770 {
3771
1/2
✓ Branch 0 taken 4276 times.
✗ Branch 1 not taken.
4276 if(!(msg_bg_display_buf->clip))
3772 4276 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3773
1/2
✓ Branch 0 taken 4276 times.
✗ Branch 1 not taken.
4276 if(!(msg_portrait_display_buf->clip))
3774 4276 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3775
1/2
✓ Branch 0 taken 4276 times.
✗ Branch 1 not taken.
4276 if(!(msg_txt_display_buf->clip))
3776 4276 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3777 4276 }
3778
3779 /*
3780 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3781 {
3782 BITMAP* subBmp = 0;
3783 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3784 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3785 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3786 destroy_bitmap(subBmp);
3787 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3788 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3789 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3790 }
3791 */
3792
3793
2/2
✓ Branch 0 taken 119393 times.
✓ Branch 1 taken 802 times.
120195 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3794
3795
2/2
✓ Branch 0 taken 119393 times.
✓ Branch 1 taken 802 times.
120195 if(nosubscr)
3796 {
3797 802 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3798 802 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3799 802 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3800 802 }
3801
3802 //TODO: Optimize blit 'overcalls' -Gleeok
3803
2/2
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 119393 times.
120195 BITMAP *source = nosubscr ? panorama : wavybuf;
3804 120195 blit(source,framebuf,0,0,0,0,256,224);
3805
3806 120195 update_hw_screen();
3807 120195 }
3808
3809 //----------------------------------------------------------------
3810
3811 PALETTE sys_pal;
3812
3813 int32_t onGUISnapshot()
3814 {
3815 char buf[200];
3816 int32_t num=0;
3817 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3818 do
3819 {
3820 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3821 }
3822 while(num<99999 && exists(buf));
3823
3824 BITMAP *b = create_bitmap_ex(8,resx,resy);
3825
3826 if(b)
3827 {
3828 if(MenuOpen)
3829 {
3830 //Cannot load game's palette while GUI elements are in focus. -Z
3831 //If there is a way to do this, then I have missed it.
3832 /*
3833 game_pal();
3834 RAMpal[253] = _RGB(0,0,0);
3835 RAMpal[254] = _RGB(63,63,63);
3836 set_palette_range(RAMpal,0,255,false);
3837 memcpy(RAMpal, snappal, sizeof(snappal));
3838 create_rgb_table(&rgb_table, RAMpal, NULL);
3839 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3840 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3841
3842 for(int32_t q=0; q<PAL_SIZE; q++)
3843 {
3844 trans_table2.data[0][q] = q;
3845 trans_table2.data[q][q] = q;
3846 }
3847 */
3848 //ringcolor(false);
3849 //get_palette(RAMpal);
3850 blit(screen,b,0,0,0,0,resx,resy);
3851 //al_trace("Menu Open\n");
3852 //game_pal();
3853 //PALETTE temppal;
3854 //get_palette(temppal);
3855 //system_pal();
3856 save_bitmap(buf,b,sys_pal);
3857 //save_bitmap(buf,b,RAMpal);
3858 //save_bitmap(buf,b,snappal);
3859 }
3860 else
3861 {
3862 blit(screen,b,0,0,0,0,resx,resy);
3863 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3864 }
3865 destroy_bitmap(b);
3866 }
3867
3868 return D_O_K;
3869 }
3870
3871 int32_t onNonGUISnapshot()
3872 {
3873 PALETTE temppal;
3874 get_palette(temppal);
3875 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3876
3877 char buf[200];
3878 int32_t num=0;
3879
3880 do
3881 {
3882 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3883 }
3884 while(num<99999 && exists(buf));
3885
3886 BITMAP *panorama = create_bitmap_ex(8,256,168);
3887 /*
3888 PALETTE tempRAMpal;
3889 get_palette(tempRAMpal);
3890
3891 if(tmpscr->flags3&fNOSUBSCR)
3892 {
3893 clear_to_color(panorama,0);
3894 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3895 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3896 }
3897 else
3898 {
3899 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3900 }
3901
3902 destroy_bitmap(panorama);
3903 return D_O_K;
3904 */
3905 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3906 {
3907 clear_to_color(panorama,0);
3908 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3909 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3910 }
3911 else
3912 {
3913 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3914 }
3915
3916 destroy_bitmap(panorama);
3917 return D_O_K;
3918 }
3919
3920 int32_t onSnapshot()
3921 {
3922 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3923 {
3924 onGUISnapshot();
3925 }
3926 else
3927 {
3928 onNonGUISnapshot();
3929 }
3930
3931 return D_O_K;
3932 }
3933
3934 int32_t onSaveMapPic()
3935 {
3936 int32_t mapres2 = 0;
3937 char buf[200];
3938 int32_t num=0;
3939 mapscr tmpscr_b[2];
3940 mapscr tmpscr_c[6];
3941 BITMAP* _screen_draw_buffer = NULL;
3942 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3943 set_clip_state(_screen_draw_buffer,1);
3944
3945 for(int32_t i=0; i<6; ++i)
3946 {
3947 tmpscr_c[i] = tmpscr2[i];
3948 tmpscr2[i].zero_memory();
3949
3950 if(i>=2)
3951 {
3952 continue;
3953 }
3954
3955 tmpscr_b[i] = tmpscr[i];
3956 tmpscr[i].zero_memory();
3957 }
3958
3959 do
3960 {
3961 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3962 }
3963 while(num<99999 && exists(buf));
3964
3965 BITMAP* mappic = NULL;
3966
3967
3968 bool done=false, redraw=true;
3969
3970 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3971
3972 if(!mappic)
3973 {
3974 system_pal();
3975 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3976 game_pal();
3977 return D_O_K;;
3978 }
3979
3980 // draw the map
3981 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3982
3983 for(int32_t y=0; y<8; y++)
3984 {
3985 for(int32_t x=0; x<16; x++)
3986 {
3987 if(!displayOnMap(x, y))
3988 {
3989 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3990 }
3991 else
3992 {
3993 int32_t s = (y<<4) + x;
3994 loadscr2(1,s,-1);
3995
3996 for(int32_t i=0; i<6; i++)
3997 {
3998 if(tmpscr[1].layermap[i]<=0)
3999 continue;
4000
4001 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4002 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4003 {
4004 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4005
4006 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4007 }
4008 }
4009
4010 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4011
4012 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4013
4014 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4015 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4016
4017 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4018
4019 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4020 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4021 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4022 {
4023 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4024 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4025 }
4026 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4027
4028 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4029
4030 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4031 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4032 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4033 {
4034 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4035 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4036 }
4037 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4038 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4039
4040 }
4041
4042 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4043 }
4044 }
4045
4046 for(int32_t i=0; i<6; ++i)
4047 {
4048 tmpscr2[i]=tmpscr_c[i];
4049
4050 if(i>=2)
4051 {
4052 continue;
4053 }
4054
4055 tmpscr[i]=tmpscr_b[i];
4056 }
4057
4058 save_bitmap(buf,mappic,RAMpal);
4059 destroy_bitmap(mappic);
4060 destroy_bitmap(_screen_draw_buffer);
4061 return D_O_K;
4062 }
4063
4064 /*
4065 int32_t onSaveMapPic()
4066 {
4067 BITMAP* mappic = NULL;
4068 BITMAP* _screen_draw_buffer = NULL;
4069 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4070 int32_t mapres2 = 0;
4071 char buf[20];
4072 int32_t num=0;
4073 set_clip_state(_screen_draw_buffer,1);
4074 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4075
4076 do
4077 {
4078 sprintf(buf, "zelda%03d.png", ++num);
4079 }
4080 while(num<999 && exists(buf));
4081
4082 // if(!mappic) {
4083 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4084
4085 if(!mappic)
4086 {
4087 system_pal();
4088 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4089 game_pal();
4090 return D_O_K;
4091 }
4092
4093 // }
4094
4095 int32_t layermap, layerscreen;
4096 int32_t x2=0;
4097
4098 // draw the map
4099 for(int32_t y=0; y<8; y++)
4100 {
4101 for(int32_t x=0; x<16; x++)
4102 {
4103 int32_t s = (y<<4) + x;
4104
4105 if(!displayOnMap(x, y))
4106 {
4107 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4108 }
4109 else
4110 {
4111 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4112 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4113
4114 for(int32_t k=0; k<4; k++)
4115 {
4116 if(k==2)
4117 {
4118 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4119 }
4120
4121 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4122
4123 if(layermap>-1)
4124 {
4125 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4126
4127 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4128 {
4129 for(int32_t i=0; i<176; i++)
4130 {
4131 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4132 }
4133 }
4134 else
4135 {
4136 for(int32_t i=0; i<176; i++)
4137 {
4138 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4139 }
4140 }
4141 }
4142 }
4143
4144 for(int32_t i=0; i<176; i++)
4145 {
4146 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4147 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4148 {
4149 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4150 }
4151 }
4152
4153 for(int32_t k=4; k<6; k++)
4154 {
4155 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4156
4157 if(layermap>-1)
4158 {
4159 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4160
4161 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4162 {
4163 for(int32_t i=0; i<176; i++)
4164 {
4165 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4166 }
4167 }
4168 else
4169 {
4170 for(int32_t i=0; i<176; i++)
4171 {
4172 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4173 }
4174 }
4175 }
4176 }
4177 }
4178
4179 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4180 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4181 }
4182
4183 }
4184
4185 save_bitmap(buf,mappic,RAMpal);
4186 destroy_bitmap(mappic);
4187 destroy_bitmap(_screen_draw_buffer);
4188 return D_O_K;
4189 }
4190 */
4191
4192 3 void f_Quit(int32_t type)
4193 {
4194
3/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
3 if(type==qQUIT && !Playing)
4195 1 return;
4196
4197 2 bool from_menu = is_sys_pal;
4198
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!from_menu)
4200 {
4201 2 music_pause();
4202 2 pause_all_sfx();
4203 2 }
4204 2 enter_sys_pal();
4205 2 clear_keybuf();
4206
4207 2 replay_poll();
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (replay_is_replaying())
4209 2 replay_peek_quit();
4210
4211
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (!replay_is_replaying())
4212 switch(type)
4213 {
4214 case qQUIT:
4215 onQuit();
4216 break;
4217
4218 case qRESET:
4219 onReset();
4220 break;
4221
4222 case qEXIT:
4223 onExit();
4224 break;
4225 }
4226
4227
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(Quit)
4228 {
4229 2 kill_sfx();
4230 2 music_stop();
4231 2 exit_sys_pal();
4232 2 update_hw_screen();
4233 2 }
4234 else
4235 {
4236 exit_sys_pal();
4237 if(!from_menu)
4238 {
4239 music_resume();
4240 resume_all_sfx();
4241 }
4242 }
4243
4244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!from_menu)
4245 2 show_mouse(NULL);
4246 2 eat_buttons();
4247
4248 2 zc_readrawkey(KEY_ESC);
4249
4250 2 zc_readrawkey(KEY_ENTER);
4251 3 }
4252
4253 //----------------------------------------------------------------
4254
4255 int32_t onNoWalls()
4256 {
4257 cheats_enqueue(Cheat::Walls);
4258 return D_O_K;
4259 }
4260
4261 int32_t onIgnoreSideview()
4262 {
4263 cheats_enqueue(Cheat::IgnoreSideView);
4264 return D_O_K;
4265 }
4266
4267 123163 int32_t input_idle(bool checkmouse)
4268 {
4269 static int32_t mx, my, mz, mb;
4270
4271
4/6
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26800 times.
✓ Branch 3 taken 96363 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26800 times.
149963 if(keypressed() || zc_key_pressed() ||
4272
4/8
✓ Branch 0 taken 26800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26800 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26800 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26800 times.
✗ Branch 7 not taken.
26800 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4273 {
4274 96363 idle_count = 0;
4275
4276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96363 times.
96363 if(active_count < MAX_ACTIVE)
4277 {
4278 96363 ++active_count;
4279 96363 }
4280 96363 }
4281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26800 times.
26800 else if(idle_count < MAX_IDLE)
4282 {
4283 26800 ++idle_count;
4284 26800 active_count = 0;
4285 26800 }
4286
4287 123163 mx = mouse_x;
4288 123163 my = mouse_y;
4289 123163 mz = mouse_z;
4290 123163 mb = mouse_b;
4291
4292 123163 return idle_count;
4293 }
4294
4295 int32_t onGoFast()
4296 {
4297 cheats_enqueue(Cheat::Fast);
4298 return D_O_K;
4299 }
4300
4301 int32_t onKillCheat()
4302 {
4303 cheats_enqueue(Cheat::Kill);
4304 return D_O_K;
4305 }
4306
4307 int32_t onShowLayer0()
4308 {
4309 show_layer_0 = !show_layer_0;
4310 return D_O_K;
4311 }
4312 int32_t onShowLayer1()
4313 {
4314 show_layer_1 = !show_layer_1;
4315 return D_O_K;
4316 }
4317 int32_t onShowLayer2()
4318 {
4319 show_layer_2 = !show_layer_2;
4320 return D_O_K;
4321 }
4322 int32_t onShowLayer3()
4323 {
4324 show_layer_3 = !show_layer_3;
4325 return D_O_K;
4326 }
4327 int32_t onShowLayer4()
4328 {
4329 show_layer_4 = !show_layer_4;
4330 return D_O_K;
4331 }
4332 int32_t onShowLayer5()
4333 {
4334 show_layer_5 = !show_layer_5;
4335 return D_O_K;
4336 }
4337 int32_t onShowLayer6()
4338 {
4339 show_layer_6 = !show_layer_6;
4340 return D_O_K;
4341 }
4342 int32_t onShowLayerO()
4343 {
4344 show_layer_over=!show_layer_over;
4345 return D_O_K;
4346 }
4347 int32_t onShowLayerP()
4348 {
4349 show_layer_push=!show_layer_push;
4350 return D_O_K;
4351 }
4352 int32_t onShowLayerS()
4353 {
4354 show_sprites=!show_sprites;
4355 return D_O_K;
4356 }
4357 int32_t onShowLayerF()
4358 {
4359 show_ffcs=!show_ffcs;
4360 return D_O_K;
4361 }
4362 int32_t onShowLayerW()
4363 {
4364 show_walkflags=!show_walkflags;
4365 return D_O_K;
4366 }
4367 int32_t onShowLayerE()
4368 {
4369 show_effectflags=!show_effectflags;
4370 return D_O_K;
4371 }
4372 int32_t onShowFFScripts()
4373 {
4374 show_ff_scripts=!show_ff_scripts;
4375 return D_O_K;
4376 }
4377 int32_t onShowHitboxes()
4378 {
4379 show_hitboxes=!show_hitboxes;
4380 return D_O_K;
4381 }
4382
4383 int32_t onLightSwitch()
4384 {
4385 cheats_enqueue(Cheat::Light);
4386 return D_O_K;
4387 }
4388
4389 int32_t onGoTo();
4390 int32_t onGoToComplete();
4391
4392 123163 void syskeys()
4393 {
4394 123163 update_system_keys();
4395
4396 int32_t oldtitle_version;
4397
4398
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(close_button_quit)
4399 {
4400 close_button_quit=false;
4401 f_Quit(qEXIT);
4402 }
4403
4404 123163 poll_joystick();
4405
4406
2/10
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 123163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
123163 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4407 {
4408 oldtitle_version=title_version;
4409 System();
4410 }
4411
4412 123163 mouse_down=gui_mouse_b();
4413
4414
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(zc_read_system_key(KEY_F1))
4415 {
4416 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4417 {
4418 halt=!halt;
4419 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4420 }
4421 else
4422 {
4423 Throttlefps=!Throttlefps;
4424 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4425 logic_counter=0;
4426 }
4427 }
4428
4429 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4430 /*
4431 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4432 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4433 */
4434
4435
1/4
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123163 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4436
4437
1/4
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123163 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4438
4439
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(zc_read_system_key(KEY_F2))
4440 {
4441 ShowFPS=!ShowFPS;
4442 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4443 }
4444
4445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123163 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4446
4447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123163 if(zc_read_system_key(KEY_F4) && Playing)
4448 {
4449 Paused=true;
4450 Advance=true;
4451 }
4452
4453
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(zc_read_system_key(KEY_F6)) onTryQuit();
4454
4455 #ifndef ALLEGRO_MACOSX
4456 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4457
4458 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4459 #else
4460
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4461
4462
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4463 #endif
4464
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
123163 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4465
4466
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if (zc_read_system_key(KEY_F12))
4467 {
4468 onSnapshot();
4469 }
4470
4471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123163 if(debug_enabled && zc_read_system_key(KEY_TAB))
4472 set_debug(!get_debug());
4473
4474
3/4
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 104433 times.
123163 if(get_debug() || cheat>=1)
4475 {
4476
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4477 {
4478 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4479
4480 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4481
4482 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4483
4484 if(zc_readkey(KEY_B))
4485 {
4486 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4487 }
4488
4489 if(zc_readkey(KEY_A))
4490 {
4491 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4492 }
4493 }
4494 18730 }
4495
4496
3/4
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 104433 times.
123163 if(get_debug() || cheat>=2)
4497 {
4498
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4499 {
4500 if(rI())
4501 {
4502 cheats_enqueue(Cheat::Clock);
4503 }
4504 }
4505 18730 }
4506
4507
3/4
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 104433 times.
123163 if(get_debug() || cheat>=4)
4508 {
4509
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4510 {
4511 if(rF11())
4512 {
4513 cheats_enqueue(Cheat::Walls);
4514 }
4515
4516 if(rQ())
4517 {
4518 cheats_enqueue(Cheat::Fast);
4519 }
4520
4521 if(zc_readkey(KEY_F))
4522 {
4523 cheats_enqueue(Cheat::Freeze);
4524 }
4525
4526 if(zc_readkey(KEY_G)) onGoToComplete();
4527
4528 if(zc_readkey(KEY_0)) onShowLayer0();
4529
4530 if(zc_readkey(KEY_1)) onShowLayer1();
4531
4532 if(zc_readkey(KEY_2)) onShowLayer2();
4533
4534 if(zc_readkey(KEY_3)) onShowLayer3();
4535
4536 if(zc_readkey(KEY_4)) onShowLayer4();
4537
4538 if(zc_readkey(KEY_5)) onShowLayer5();
4539
4540 if(zc_readkey(KEY_6)) onShowLayer6();
4541
4542 //if(zc_readkey(KEY_7)) onShowLayerO();
4543 if(zc_readkey(KEY_7)) onShowLayerF();
4544
4545 if(zc_readkey(KEY_8)) onShowLayerS();
4546
4547 if(zc_readkey(KEY_W)) onShowLayerW();
4548
4549 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4550
4551 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4552
4553 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4554 if(zc_readkey(KEY_O)) onShowLayerO();
4555 if(zc_readkey(KEY_P)) onShowLayerP();
4556 if(zc_readkey(KEY_C)) onShowHitboxes();
4557 if(zc_readkey(KEY_F)) onShowFFScripts();
4558 }
4559 18730 }
4560
4561
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(volkeys)
4562 {
4563 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4564
4565 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4566
4567 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4568
4569 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4570 }
4571
4572
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123163 if(!get_debug() || !SystemKeys || replay_is_replaying())
4573 123163 goto bottom;
4574
4575 if(zc_readkey(KEY_D))
4576 {
4577 details = !details;
4578 rectfill(screen,0,0,319,7,BLACK);
4579 rectfill(screen,0,8,31,239,BLACK);
4580 rectfill(screen,288,8,319,239,BLACK);
4581 rectfill(screen,32,232,287,239,BLACK);
4582 }
4583
4584 if(zc_readkey(KEY_P)) Paused=!Paused;
4585
4586 //if(zc_readkey(KEY_P)) centerHero();
4587 if(zc_readkey(KEY_A))
4588 {
4589 Paused=true;
4590 Advance=true;
4591 }
4592
4593 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4594 #ifndef ALLEGRO_MACOSX
4595 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4596
4597 if(zc_readkey(KEY_F7))
4598 {
4599 Matrix(ss_speed, ss_density, 0);
4600 game_pal();
4601 }
4602 #else
4603 // The reason these are different on Mac in the first place is that
4604 // the OS doesn't let us use F9 and F10...
4605 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4606
4607 if(zc_readkey(KEY_F9))
4608 {
4609 Matrix(ss_speed, ss_density, 0);
4610 game_pal();
4611 }
4612 #endif
4613 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4614 {
4615 //change containers
4616 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4617 {
4618 //magic containers
4619 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4620 {
4621 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4622 }
4623 else
4624 {
4625 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4626 }
4627 }
4628 else
4629 {
4630 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4631 {
4632 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4633 }
4634 else
4635 {
4636 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4637 }
4638 }
4639 }
4640
4641 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4642 {
4643 //change containers
4644 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4645 {
4646 //magic containers
4647 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4648 {
4649 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4650 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4651 //heart containers
4652 }
4653 else
4654 {
4655 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4656 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4657 }
4658 }
4659 else
4660 {
4661 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4662 {
4663 game->set_magic(zc_max(game->get_magic()-1,0));
4664 }
4665 else
4666 {
4667 game->set_life(zc_max(game->get_life()-1,0));
4668 }
4669 }
4670 }
4671
4672 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4673
4674 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4675
4676 verifyBothWeapons();
4677
4678 bottom:
4679
4680
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(input_idle(true) > after_time())
4681 {
4682 Matrix(ss_speed, ss_density, 0);
4683 game_pal();
4684 }
4685 //Saffith's method of separating system and game key bindings. Can't do this!!
4686 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4687
4688 //while(Playing && keypressed())
4689 //readkey();
4690 // What's the Playing check for?
4691 123163 clear_keybuf();
4692 123163 }
4693
4694 291769 void checkQuitKeys()
4695 {
4696 #ifndef ALLEGRO_MACOSX
4697 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4698
4699 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4700 #else
4701
1/2
✓ Branch 0 taken 291769 times.
✗ Branch 1 not taken.
291769 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4702
4703
1/2
✓ Branch 0 taken 291769 times.
✗ Branch 1 not taken.
291769 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4704 #endif
4705 291769 }
4706
4707 56190 bool CheatModifierKeys()
4708 {
4709 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4710 // to trigger cheats.
4711
1/2
✓ Branch 0 taken 56190 times.
✗ Branch 1 not taken.
56190 if (replay_is_replaying())
4712 56190 return false;
4713
4714 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4715 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4716 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4717 {
4718 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4719 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4720 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4721 {
4722 return true;
4723 }
4724 }
4725 return false;
4726 56190 }
4727
4728 //99:05:54, for some reason?
4729 #define OLDMAXTIME 21405240
4730 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4731 #define MAXTIME 1944000000
4732
4733 120196 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4734 {
4735
2/2
✓ Branch 0 taken 100779 times.
✓ Branch 1 taken 19417 times.
120196 if(zcmusic!=NULL)
4736 {
4737 19417 zcmusic_poll();
4738 19417 }
4739
4740
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 120196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 120196 times.
120196 while(Paused && !Advance && !Quit)
4741 {
4742 // have to call this, otherwise we'll get an infinite loop
4743 syskeys();
4744 if(allowF6Script)
4745 {
4746 FFCore.runF6Engine();
4747 }
4748 if (replay_get_mode() != ReplayMode::Assert)
4749 updatescr(allowwavy);
4750 throttleFPS();
4751
4752 #ifdef _WIN32
4753
4754 if(use_dwm_flush)
4755 {
4756 do_DwmFlush();
4757 }
4758
4759 #endif
4760
4761 // to keep music playing
4762 if(zcmusic!=NULL)
4763 {
4764 zcmusic_poll();
4765 }
4766
4767 update_hw_screen();
4768 }
4769
4770
2/2
✓ Branch 0 taken 120195 times.
✓ Branch 1 taken 1 times.
120196 if(Quit)
4771 1 return;
4772
4773
3/4
✓ Branch 0 taken 100117 times.
✓ Branch 1 taken 20078 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100117 times.
120195 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4774 100117 game->change_time(1);
4775
4776 120195 Advance=false;
4777
4778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120195 times.
120195 if (replay_is_active())
4779 {
4780
2/2
✓ Branch 0 taken 37667 times.
✓ Branch 1 taken 82528 times.
120195 if (replay_get_version() >= 3)
4781 82528 replay_poll();
4782
4783 // Replay compatability.
4784
4/4
✓ Branch 0 taken 36044 times.
✓ Branch 1 taken 84151 times.
✓ Branch 2 taken 14990 times.
✓ Branch 3 taken 21054 times.
120195 if (replay_get_version() >= 6 && replay_get_version() < 8)
4785 21054 replay_peek_input();
4786
2/2
✓ Branch 0 taken 14990 times.
✓ Branch 1 taken 105205 times.
120195 if (replay_get_version() < 8)
4787 105205 update_keys();
4788 120195 }
4789
4790 120195 ++frame;
4791
4792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120195 times.
120195 if (replay_is_replaying())
4793 120195 replay_do_cheats();
4794 120195 syskeys();
4795
4796 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4797 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4798 // approach here means it doesn't matter which call adds the cheat.
4799 120195 cheats_execute_queued();
4800
4801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120195 times.
120195 if (replay_is_replaying())
4802 120195 replay_peek_quit();
4803
2/2
✓ Branch 0 taken 120192 times.
✓ Branch 1 taken 3 times.
120195 if (GameFlags & GAMEFLAG_TRYQUIT)
4804 3 replay_step_quit(0);
4805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120195 times.
120195 if(allowF6Script)
4806 {
4807 120195 FFCore.runF6Engine();
4808 120195 }
4809
2/2
✓ Branch 0 taken 120180 times.
✓ Branch 1 taken 15 times.
120195 if (Quit)
4810 15 replay_step_quit(Quit);
4811 // Someday... maybe install a Turbo button here?
4812 120195 updatescr(allowwavy);
4813 120195 throttleFPS();
4814
4815 #ifdef _WIN32
4816
4817 if(use_dwm_flush)
4818 {
4819 do_DwmFlush();
4820 }
4821
4822 #endif
4823
4824 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4825
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 119899 times.
120195 if(sfxcleanup)
4826 119899 sfx_cleanup();
4827 120196 }
4828
4829 void zapout()
4830 {
4831 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4832 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4833
4834 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4835 script_drawing_commands.Clear();
4836
4837 // zap out
4838 for(int32_t i=1; i<=24; i++)
4839 {
4840 draw_fuzzy(i);
4841 syskeys();
4842 advanceframe(true);
4843
4844 if(Quit)
4845 {
4846 break;
4847 }
4848 }
4849 }
4850
4851 void zapin()
4852 {
4853 FFCore.warpScriptCheck();
4854 draw_screen(tmpscr);
4855 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4856 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4857 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4858
4859 // zap out
4860 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4861 for(int32_t i=24; i>=1; i--)
4862 {
4863 draw_fuzzy(i);
4864 syskeys();
4865 advanceframe(true);
4866
4867 if(Quit)
4868 {
4869 break;
4870 }
4871 }
4872 }
4873
4874
4875 void wavyout(bool showhero)
4876 {
4877 draw_screen(tmpscr, showhero);
4878 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4879
4880 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4881 clear_to_color(wavebuf,0);
4882 blit(framebuf,wavebuf,0,0,16,0,256,224);
4883
4884 static PALETTE wavepal;
4885
4886 int32_t ofs;
4887 int32_t amplitude=8;
4888
4889 int32_t wavelength=4;
4890 double palpos=0, palstep=4, palstop=126;
4891
4892 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4893 for(int32_t i=0; i<168; i+=wavelength)
4894 {
4895 for(int32_t l=0; l<256; l++)
4896 {
4897 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4898 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4899 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4900 }
4901
4902 palpos+=palstep;
4903
4904 if(palpos>=0)
4905 {
4906 hw_palette = &wavepal;
4907 update_hw_pal = true;
4908 }
4909 else
4910 {
4911 hw_palette = &RAMpal;
4912 update_hw_pal = true;
4913 }
4914
4915 for(int32_t j=0; j+playing_field_offset<224; j++)
4916 {
4917 for(int32_t k=0; k<256; k++)
4918 {
4919 ofs=0;
4920
4921 if((j<i)&&(j&1))
4922 {
4923 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4924 }
4925
4926 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4927 }
4928 }
4929
4930 syskeys();
4931 advanceframe(true);
4932
4933 // animate_combos();
4934 if(Quit)
4935 break;
4936 }
4937
4938 destroy_bitmap(wavebuf);
4939 }
4940
4941 void wavyin()
4942 {
4943 draw_screen(tmpscr);
4944 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4945
4946 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4947 clear_to_color(wavebuf,0);
4948 blit(framebuf,wavebuf,0,0,16,0,256,224);
4949
4950 static PALETTE wavepal;
4951
4952 //Breaks dark rooms.
4953 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4954 /*
4955 loadfullpal();
4956 loadlvlpal(DMaps[currdmap].color);
4957 ringcolor(false);
4958 */
4959 refreshpal=false;
4960 int32_t ofs;
4961 int32_t amplitude=8;
4962 int32_t wavelength=4;
4963 double palpos=168, palstep=4, palstop=126;
4964
4965 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4966 for(int32_t i=0; i<168; i+=wavelength)
4967 {
4968 for(int32_t l=0; l<256; l++)
4969 {
4970 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4971 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4972 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4973 }
4974
4975 palpos-=palstep;
4976
4977 if(palpos>=0)
4978 {
4979 hw_palette = &wavepal;
4980 update_hw_pal = true;
4981 }
4982 else
4983 {
4984 hw_palette = &RAMpal;
4985 update_hw_pal = true;
4986 }
4987
4988 for(int32_t j=0; j+playing_field_offset<224; j++)
4989 {
4990 for(int32_t k=0; k<256; k++)
4991 {
4992 ofs=0;
4993
4994 if((j<(167-i))&&(j&1))
4995 {
4996 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4997 }
4998
4999 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5000 }
5001 }
5002
5003 syskeys();
5004 advanceframe(true);
5005 // animate_combos();
5006
5007 if(Quit)
5008 break;
5009 }
5010
5011 destroy_bitmap(wavebuf);
5012 }
5013
5014 33 void blackscr(int32_t fcnt,bool showsubscr)
5015 {
5016 33 reset_pal_cycling();
5017 33 script_drawing_commands.Clear();
5018
5019 33 FFCore.warpScriptCheck();
5020 33 bool showtime = game->should_show_time();
5021
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 990 times.
1023 while(fcnt>0)
5022 {
5023 990 clear_bitmap(framebuf);
5024
5025
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 450 times.
990 if(showsubscr)
5026 {
5027 450 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5028
2/4
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 450 times.
450 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5029 {
5030 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5031 }
5032 450 }
5033
5034 990 syskeys();
5035 990 advanceframe(true);
5036
5037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 990 times.
990 if(Quit)
5038 break;
5039
5040 990 --fcnt;
5041 }
5042 33 }
5043
5044 27 void openscreen(int32_t shape)
5045 {
5046 27 reset_pal_cycling();
5047 27 black_opening_count=0;
5048
5049
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
27 if(COOLSCROLL || shape>-1)
5050 {
5051 13 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5052 13 return;
5053 }
5054 else
5055 {
5056 14 Hero.setDontDraw(true);
5057 14 show_subscreen_dmap_dots=false;
5058 14 show_subscreen_numbers=false;
5059 // show_subscreen_items=false;
5060 14 show_subscreen_life=false;
5061 }
5062
5063 14 int32_t x=128;
5064
5065 14 FFCore.warpScriptCheck();
5066
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1120 times.
1134 for(int32_t i=0; i<80; i++)
5067 {
5068 1120 draw_screen(tmpscr);
5069 //? draw_screen already draws the subscreen -DD
5070 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5071 1120 x=128-(((i*128/80)/8)*8);
5072
5073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
1120 if(x>0)
5074 {
5075 1120 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5076 1120 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5077 1120 }
5078
5079 // x=((80-i)/2)*4;
5080 /*
5081 --x;
5082 switch(++c)
5083 {
5084 case 5: c=0;
5085 case 0:
5086 case 2:
5087 case 3: --x; break;
5088 }
5089 */
5090 1120 syskeys();
5091 1120 advanceframe(true);
5092
5093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
1120 if(Quit)
5094 {
5095 break;
5096 }
5097 1120 }
5098
5099 14 Hero.setDontDraw(false);
5100 14 show_subscreen_items=true;
5101 14 show_subscreen_dmap_dots=true;
5102 27 }
5103
5104 void closescreen(int32_t shape)
5105 {
5106 reset_pal_cycling();
5107 black_opening_count=0;
5108
5109 if(COOLSCROLL || shape>-1)
5110 {
5111 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5112 return;
5113 }
5114 else
5115 {
5116 Hero.setDontDraw(true);
5117 show_subscreen_dmap_dots=false;
5118 show_subscreen_numbers=false;
5119 // show_subscreen_items=false;
5120 show_subscreen_life=false;
5121 }
5122
5123 int32_t x=128;
5124
5125 FFCore.warpScriptCheck();
5126 for(int32_t i=79; i>=0; --i)
5127 {
5128 draw_screen(tmpscr);
5129 //? draw_screen already draws the subscreen -DD
5130 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5131 x=128-(((i*128/80)/8)*8);
5132
5133 if(x>0)
5134 {
5135 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5136 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5137 }
5138
5139 // x=((80-i)/2)*4;
5140 /*
5141 --x;
5142 switch(++c)
5143 {
5144 case 5: c=0;
5145 case 0:
5146 case 2:
5147 case 3: --x; break;
5148 }
5149 */
5150 syskeys();
5151 advanceframe(true);
5152
5153 if(Quit)
5154 {
5155 break;
5156 }
5157 }
5158
5159 Hero.setDontDraw(false);
5160 show_subscreen_items=true;
5161 show_subscreen_dmap_dots=true;
5162 }
5163
5164 int32_t TriforceCount()
5165 {
5166 int32_t c=0;
5167
5168 for(int32_t i=1; i<=8; i++)
5169 if(game->lvlitems[i]&liTRIFORCE)
5170 ++c;
5171
5172 return c;
5173 }
5174
5175 int32_t onCustomGame()
5176 {
5177 int32_t file = getsaveslot();
5178
5179 if(file < 0)
5180 return D_O_K;
5181
5182 bool ret = (custom_game(file)!=0);
5183 return ret ? D_CLOSE : D_O_K;
5184 }
5185
5186 int32_t onContinue()
5187 {
5188 return D_CLOSE;
5189 }
5190
5191 int32_t onEsc() // Unused?? -L
5192 {
5193 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5194 }
5195
5196 int32_t onVsync()
5197 {
5198 Throttlefps = !Throttlefps;
5199 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5200 return D_O_K;
5201 }
5202
5203 int32_t onWinPosSave()
5204 {
5205 SaveWinPos = !SaveWinPos;
5206 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5207 return D_O_K;
5208 }
5209
5210 int32_t onClickToFreeze()
5211 {
5212 ClickToFreeze = !ClickToFreeze;
5213 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5214 return D_O_K;
5215 }
5216
5217 int32_t OnSaveZCConfig()
5218 {
5219 if(jwin_alert3(
5220 "Save Configuration",
5221 "Are you sure that you wish to save your present configuration settings?",
5222 "This will overwrite your prior settings!",
5223 NULL,
5224 "&Yes",
5225 "&No",
5226 NULL,
5227 'y',
5228 'n',
5229 0,
5230 lfont) == 1)
5231 {
5232 save_game_configs();
5233 return D_O_K;
5234 }
5235 else return D_O_K;
5236 }
5237
5238 int32_t OnnClearQuestDir()
5239 {
5240 if(jwin_alert3(
5241 "Clear Current Directory Cache",
5242 "Are you sure that you wish to clear the current cached directory?",
5243 "This will default the current directory to the ROOT for this instance of ZC Player!",
5244 NULL,
5245 "&Yes",
5246 "&No",
5247 NULL,
5248 'y',
5249 'n',
5250 0,
5251 lfont) == 1)
5252 {
5253 zc_set_config("zeldadx","win_qst_dir","");
5254 flush_config_file();
5255 strcpy(qstdir,"");
5256 #ifdef __EMSCRIPTEN__
5257 em_sync_fs();
5258 #endif
5259 return D_O_K;
5260 }
5261 else return D_O_K;
5262 }
5263
5264
5265 int32_t onConsoleZASM()
5266 {
5267 if ( !zasm_debugger )
5268 {
5269 AlertDialog("WARNING: ZASM Debugger",
5270 "Enabling this will open the ZASM Debugger Console"
5271 "\nThis will likely grind ZC to a halt with lag."
5272 "\nTo make any use of this, it is suggested that you read"
5273 "\nthe documentation for 'void Breakpoint(char[] string);'"
5274 " in 'ZScript_Additions.txt'"
5275 "\nThis is not recommended for normal users,"
5276 " and is only intended for ZC developers,"
5277 "\nor quest developers coding directly in ZASM"
5278 "\nAre you sure that you wish to open the ZASM Debugger?",
5279 [&](bool ret,bool)
5280 {
5281 if(ret)
5282 {
5283 FFCore.ZASMPrint(true);
5284 }
5285 }).show();
5286 return D_O_K;
5287 }
5288 else
5289 {
5290 FFCore.ZASMPrint(false);
5291 return D_O_K;
5292 }
5293 }
5294
5295
5296 int32_t onConsoleZScript()
5297 {
5298 if ( !zscript_debugger )
5299 {
5300 AlertDialog("ZScript Debugger",
5301 "Enabling this will open the ZScript Debugger Console"
5302 "\nThis will display any messages logged by scripts,"
5303 " including script errors."
5304 "\nAre you sure that you wish to open the ZScript Debugger?",
5305 [&](bool ret,bool)
5306 {
5307 if(ret)
5308 {
5309 FFCore.ZScriptConsole(true);
5310 }
5311 }).show();
5312 return D_O_K;
5313 }
5314 else
5315 {
5316 FFCore.ZScriptConsole(false);
5317 return D_O_K;
5318 }
5319 }
5320
5321 int32_t onClrConsoleOnLoad()
5322 {
5323 clearConsoleOnLoad = !clearConsoleOnLoad;
5324 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5325 return D_O_K;
5326 }
5327
5328
5329 int32_t onFrameSkip()
5330 {
5331 FrameSkip = !FrameSkip;
5332 return D_O_K;
5333 }
5334
5335 int32_t onSaveDragResize()
5336 {
5337 SaveDragResize = !SaveDragResize;
5338 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5339 return D_O_K;
5340 }
5341
5342 int32_t onDragAspect()
5343 {
5344 DragAspect = !DragAspect;
5345 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5346 return D_O_K;
5347 }
5348
5349 int32_t onTransLayers()
5350 {
5351 TransLayers = !TransLayers;
5352 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5353 return D_O_K;
5354 }
5355
5356 int32_t onNESquit()
5357 {
5358 NESquit = !NESquit;
5359 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5360 return D_O_K;
5361 }
5362
5363 int32_t onVolKeys()
5364 {
5365 volkeys = !volkeys;
5366 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5367 return D_O_K;
5368 }
5369
5370 int32_t onShowFPS()
5371 {
5372 ShowFPS = !ShowFPS;
5373 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5374 return D_O_K;
5375 }
5376
5377 14533234 bool is_Fkey(int32_t k)
5378 {
5379
2/2
✓ Branch 0 taken 1477956 times.
✓ Branch 1 taken 13055278 times.
14533234 switch(k)
5380 {
5381 case KEY_F1:
5382 case KEY_F2:
5383 case KEY_F3:
5384 case KEY_F4:
5385 case KEY_F5:
5386 case KEY_F6:
5387 case KEY_F7:
5388 case KEY_F8:
5389 case KEY_F9:
5390 case KEY_F10:
5391 case KEY_F11:
5392 case KEY_F12:
5393 1477956 return true;
5394 }
5395
5396 13055278 return false;
5397 14533234 }
5398
5399 void kb_getkey(DIALOG *d)
5400 {
5401 d->flags|=D_SELECTED;
5402
5403 scare_mouse();
5404 jwin_button_proc(MSG_DRAW,d,0);
5405 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5406 // text_mode(vc(11));
5407 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5408 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5409 unscare_mouse();
5410
5411 update_hw_screen(true);
5412
5413 clear_keybuf();
5414 int32_t k = next_press_key();
5415 clear_keybuf();
5416
5417 //shnarf
5418 //47=f1
5419 //59=esc
5420 if(k>0 && k<123 && !((k>46)&&(k<60)))
5421 *((int32_t*)d->dp3) = k;
5422
5423
5424 d->flags&=~D_SELECTED;
5425 }
5426
5427
5428 //Used by all keyboard key settings dialogues.
5429 void kb_clearjoystick(DIALOG *d)
5430 {
5431 d->flags|=D_SELECTED;
5432
5433 scare_mouse();
5434 jwin_button_proc(MSG_DRAW,d,0);
5435 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5436 // text_mode(vc(11));
5437 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5438 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5439 unscare_mouse();
5440
5441 update_hw_screen(true);
5442
5443 clear_keybuf();
5444 int32_t k = next_press_key();
5445 clear_keybuf();
5446
5447 //shnarf
5448 //47=f1
5449 //59=esc
5450 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5451 // *((int32_t*)d->dp3) = k;
5452 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5453
5454
5455 d->flags&=~D_SELECTED;
5456 }
5457
5458 //Clears key to 0.
5459 //Used by all keyboard key settings dialogues.
5460 void kb_clearkey(DIALOG *d)
5461 {
5462 d->flags|=D_SELECTED;
5463
5464 scare_mouse();
5465 jwin_button_proc(MSG_DRAW,d,0);
5466 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5467 // text_mode(vc(11));
5468 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5469 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5470 unscare_mouse();
5471
5472 update_hw_screen(true);
5473
5474 clear_keybuf();
5475 int32_t k = next_press_key();
5476 clear_keybuf();
5477
5478 //shnarf
5479 //47=f1
5480 //59=esc
5481 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5482 // *((int32_t*)d->dp3) = k;
5483 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5484
5485
5486 d->flags&=~D_SELECTED;
5487 }
5488
5489
5490 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5491 {
5492 switch(msg)
5493 {
5494 case MSG_KEY:
5495 case MSG_CLICK:
5496
5497 kb_clearjoystick(d);
5498
5499 while(gui_mouse_b())
5500 {
5501 clear_keybuf();
5502 rest(1);
5503 }
5504
5505 return D_REDRAW;
5506 }
5507
5508 return jwin_button_proc(msg,d,c);
5509 }
5510
5511 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5512 {
5513 switch(msg)
5514 {
5515 case MSG_KEY:
5516 case MSG_CLICK:
5517
5518 kb_getkey(d);
5519
5520 while(gui_mouse_b()) {
5521 clear_keybuf();
5522 rest(1);
5523 }
5524
5525 return D_REDRAW;
5526 }
5527
5528 return jwin_button_proc(msg,d,c);
5529 }
5530
5531 //Only used in keyboard settings dialogues to clear keys.
5532 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5533 {
5534 switch(msg)
5535 {
5536 case MSG_KEY:
5537 case MSG_CLICK:
5538
5539 kb_clearkey(d);
5540
5541 while(gui_mouse_b()) {
5542 clear_keybuf();
5543 rest(1);
5544 }
5545
5546 return D_REDRAW;
5547 }
5548
5549 return jwin_button_proc(msg,d,c);
5550 }
5551
5552 void j_getbtn(DIALOG *d)
5553 {
5554 d->flags|=D_SELECTED;
5555 scare_mouse();
5556 jwin_button_proc(MSG_DRAW,d,0);
5557 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5558 // text_mode(vc(11));
5559 int32_t y = gui_bmp->h/2 - 12;
5560 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5561 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5562 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5563 unscare_mouse();
5564
5565 update_hw_screen(true);
5566
5567 int32_t b = next_press_btn();
5568
5569 if(b>=0)
5570 *((int32_t*)d->dp3) = b;
5571
5572 d->flags&=~D_SELECTED;
5573
5574 if (player)
5575 player->joy_on = TRUE;
5576 }
5577
5578 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5579 {
5580 switch(msg)
5581 {
5582 case MSG_KEY:
5583 case MSG_CLICK:
5584
5585 j_getbtn(d);
5586
5587 while(gui_mouse_b()) {
5588 rest(1);
5589 clear_keybuf();
5590 }
5591
5592 return D_REDRAW;
5593 }
5594
5595 return jwin_button_proc(msg,d,c);
5596 }
5597
5598 //shnarf
5599 const char *key_str[] =
5600 {
5601 "(none) ", "a ", "b ", "c ",
5602 "d ", "e ", "f ", "g ",
5603 "h ", "i ", "j ", "k ",
5604 "l ", "m ", "n ", "o ",
5605 "p ", "q ", "r ", "s ",
5606 "t ", "u ", "v ", "w ",
5607 "x ", "y ", "z ", "0 ",
5608 "1 ", "2 ", "3 ", "4 ",
5609 "5 ", "6 ", "7 ", "8 ",
5610 "9 ", "num 0 ", "num 1 ", "num 2 ",
5611 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5612 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5613 "f2 ", "f3 ", "f4 ", "f5 ",
5614 "f6 ", "f7 ", "f8 ", "f9 ",
5615 "f10 ", "f11 ", "f12 ", "esc ",
5616 "~ ", "- ", "= ", "backspace ",
5617 "tab ", "{ ", "} ", "enter ",
5618 ": ", "quote ", "\\ ", "\\ (2) ",
5619 ", ", ". ", "/ ", "space ",
5620 "insert ", "delete ", "home ", "end ",
5621 "page up ", "page down ", "left ", "right ",
5622 "up ", "down ", "num / ", "num * ",
5623 "num - ", "num + ", "num delete ", "num enter ",
5624 "print screen ", "pause ", "abnt c1 ", "yen ",
5625 "kana ", "convert ", "no convert ", "at ",
5626 "circumflex ", ": (2) ", "kanji ", "num = ",
5627 "back quote ", "; ", "command ", "unknown (0) ",
5628 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5629 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5630 "right shift ", "left control ", "right control", "alt ",
5631 "alt gr ", "left win ", "right win ", "menu ",
5632 "scroll lock ", "number lock ", "caps lock ", "MAX"
5633 };
5634
5635
5636 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5637 //extern int32_t zcmusic_bufsz;
5638
5639 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5640 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5641
5642 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5643 {
5644 //these are here to bypass compiler warnings about unused arguments
5645 c=c;
5646
5647 if(msg==MSG_DRAW)
5648 {
5649 switch(d->w)
5650 {
5651 case 0:
5652 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5653 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5654 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5655 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5656 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5657 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5658 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5659 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5660 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5661 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5662 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5663 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5664 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5665 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5666 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5667 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5668 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5669 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5670 break;
5671
5672 case 1:
5673 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5674 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5675 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5676 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5677 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5678 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5679 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5680 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5681 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5682 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5683 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5684 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5685 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5686 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5687 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5688 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5689 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5690 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5691 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5692 break;
5693
5694 case 2:
5695 sprintf(str_a," %3d",midi_volume);
5696 sprintf(str_b," %3d",digi_volume);
5697 sprintf(str_l," %3d",emusic_volume);
5698 sprintf(str_m," %3dKB",zcmusic_bufsz);
5699 sprintf(str_r," %3d",sfx_volume);
5700 strcpy(str_s,pan_str[pan_style]);
5701 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5702 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5703 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5704 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5705 break;
5706 }
5707 }
5708
5709 return D_O_K;
5710 }
5711
5712 int32_t set_vol(void *dp3, int32_t d2)
5713 {
5714 switch(((int32_t*)dp3)[0])
5715 {
5716 case 0:
5717 midi_volume = zc_min(d2<<3,255);
5718 break;
5719
5720 case 1:
5721 digi_volume = zc_min(d2<<3,255);
5722 break;
5723
5724 case 2:
5725 emusic_volume = zc_min(d2<<3,255);
5726 break;
5727
5728 case 3:
5729 sfx_volume = zc_min(d2<<3,255);
5730 break;
5731 }
5732
5733 scare_mouse();
5734 // text_mode(vc(11));
5735 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5736 unscare_mouse();
5737 return D_O_K;
5738 }
5739
5740 int32_t set_pan(void *dp3, int32_t d2)
5741 {
5742 pan_style = vbound(d2,0,3);
5743 scare_mouse();
5744 // text_mode(vc(11));
5745 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5746 unscare_mouse();
5747 return D_O_K;
5748 }
5749
5750 int32_t set_buf(void *dp3, int32_t d2)
5751 {
5752 scare_mouse();
5753 // text_mode(vc(11));
5754 zcmusic_bufsz = d2 + 1;
5755 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5756 unscare_mouse();
5757 return D_O_K;
5758 }
5759
5760 static int32_t gamepad_btn_list[] =
5761 {
5762 6,
5763 7,8,9,10,11,12,13,14,15,16,17,
5764 18,19,20,21,22,23,24,25,26,27,28,
5765 29,30,31,32,33,34,35,36,37,38,39,
5766 -1
5767 };
5768
5769 static int32_t gamepad_dirs_list[] =
5770 {
5771 40,41,42,43,
5772 44,45,46,47,
5773 48,49,50,51,
5774 52,53,54,55,
5775 56,
5776 -1
5777 };
5778
5779 static TABPANEL gamepad_tabs[] =
5780 {
5781 // (text)
5782 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5783 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5784 { NULL, 0, NULL, 0, NULL }
5785 };
5786
5787 static DIALOG gamepad_dlg[] =
5788 {
5789 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5790 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5791 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5792 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5793 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5794 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5795 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5796 // 6
5797 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5798 // 7
5799 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5800 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5801 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5802 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5803 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5804 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5805 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5806 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5807 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5808 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5809 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5810 // 18
5811 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5812 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5813 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5814 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5815 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5816 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5817 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5818 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5819 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5820 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5821 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5822 // 29
5823 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5824 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5825 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5826 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5827 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5828 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5829 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5830 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5831 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5832 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5833 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5834 // 40
5835 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5836 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5837 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5838 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5839 // 44
5840 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5841 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5842 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5843 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5844 // 48
5845 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5846 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5847 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5848 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5849 // 52
5850 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5851 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5852 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5853 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5854 // 56
5855 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5856 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5857 };
5858
5859 static int32_t keyboard_keys_list[] =
5860 {
5861 6,7,8,9,10,
5862 11,12,13,14,15,16,17,18,19,20,
5863 21,22,23,24,25,26,27,28,29,30,
5864 31,32,33,34,35,36,37,38,39,40,
5865 -1
5866 };
5867
5868 static int32_t keyboard_dirs_list[] =
5869 {
5870 41,42,43,44,
5871 45,46,47,48,
5872 49,50,51,52,
5873 53,54,55,56,
5874 -1
5875 };
5876
5877 static int32_t keyboard_mods_list[] =
5878 {
5879 57,58,59,60,
5880 61,62,63,64,
5881 65,66,67,68,
5882 69,70,71,72,
5883 -1
5884 };
5885
5886 static TABPANEL keyboard_control_tabs[] =
5887 {
5888 // (text)
5889 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5890 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5891 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5892 { NULL, 0, NULL, 0, NULL }
5893 };
5894
5895 static DIALOG keyboard_control_dlg[] =
5896 {
5897 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5898 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5899 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5900 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5901 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5902 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5903 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5904 // Keys
5905 // 6
5906 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5907 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5908 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5909 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5910 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5911 // 11
5912 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5913 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5914 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5915 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5916 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5917 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5918 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5919 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5920 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5921 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5922 // 21
5923 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5924 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5925 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5926 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5927 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5928 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5929 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5930 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5931 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5932 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5933 // 31
5934 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5935 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5936 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5937 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5938 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5939 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5940 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5941 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5942 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5943 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5944 // Dirs
5945 // 41
5946 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5947 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5948 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5949 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5950 // 45
5951 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5952 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5953 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5954 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5955 // 49
5956 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5957 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5958 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5959 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5960 // 53
5961 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5962 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5963 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5964 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5965 // Mods
5966 // 57
5967 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5968 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5969 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5970 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5971 // 61
5972 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5973 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5974 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5975 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5976 // 65
5977 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5978 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5979 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5980 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5981 // 69
5982 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5983 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5984 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5985 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5986 // 73
5987 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5988 };
5989
5990 /*
5991 int32_t midi_dp[3] = {0,147,104};
5992 int32_t digi_dp[3] = {1,147,120};
5993 int32_t pan_dp[3] = {0,147,136};
5994 int32_t buf_dp[3] = {0,147,152};
5995 */
5996 int32_t midi_dp[3] = {0,0,0};
5997 int32_t digi_dp[3] = {1,0,0};
5998 int32_t emus_dp[3] = {2,0,0};
5999 int32_t buf_dp[3] = {0,0,0};
6000 int32_t sfx_dp[3] = {3,0,0};
6001 int32_t pan_dp[3] = {0,0,0};
6002
6003 static DIALOG sound_dlg[] =
6004 {
6005 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6006 14 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6007 14 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6008 14 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6009 14 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6010 14 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6011 14 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6012 14 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6013 14 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6014 14 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6015 14 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6016 // 10
6017 14 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6018 14 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6019 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6020 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6021 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6022 14 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6023 14 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6024 14 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6025 14 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6026 14 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6027 //20
6028 14 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6029 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6030 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6031 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6032 14 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6033 14 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6034 14 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6035 14 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6036 14 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6037 14 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6038 //30
6039 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6040 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6041 14 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6042 14 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6043 };
6044
6045 char zc_builddate[80];
6046 char zc_aboutstr[80];
6047
6048 static DIALOG about_dlg[] =
6049 {
6050 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6051 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6052 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6053 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6054 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6055 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6056 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6057 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6058 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6059 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6060 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6061 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6062 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6063 };
6064
6065
6066 static DIALOG quest_dlg[] =
6067 {
6068 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6069 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6070 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6071 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6072 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6073 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6074 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6075 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6076 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6077 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6078 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6079 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6080 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6081 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6082 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6083 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6084 };
6085
6086 static DIALOG triforce_dlg[] =
6087 {
6088 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6089 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6090 // 1
6091 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6092 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6093 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6094 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6095 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6096 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6097 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6098 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6099 // 9
6100 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6101 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6102 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6103 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6104 };
6105
6106 /*static DIALOG equip_dlg[] =
6107 {
6108 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6109 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6110 // 1
6111 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6112 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6113 // 3
6114 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6115 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6116 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6117 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6118 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6119 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6120 // 9
6121 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6122 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6123 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6124 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6125 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6126 // 14
6127 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6128 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6129 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6130 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6131 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6132 // 19
6133 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6134 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6135 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6136 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6137 // 23
6138 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6139 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6140 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6141 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6142 // 27
6143 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6144 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6145 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6146 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6147 // 31
6148 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6149 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6150 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6151 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6152 // 35
6153 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6154 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6155 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6156 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6157 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6158 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6159 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6160 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6161 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6162 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6163 };
6164
6165 static DIALOG items_dlg[] =
6166 {
6167 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6168 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6169 //1
6170 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6171 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6172 // 3
6173 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6174 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6175 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6176 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6177 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6178 // 8
6179 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6180 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6181 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6182 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6183 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6184 // 13
6185 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6186 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6187 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6188 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6189 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6190 // 18
6191 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6192 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6193 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6194 // 21
6195 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6196 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6197 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6198 // 24
6199 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6200 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6201 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6202 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6203 // 28
6204 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6205 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6206 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6207 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6208 // 32
6209 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6210 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6211 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6212 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6213 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6214 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6215 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6216 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6217 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6218 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6219 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6220 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6221 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6222 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6223 //45
6224 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6225 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6226 };*/
6227
6228
6229
6230 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6231 {
6232 go();
6233 int32_t ret=0;
6234 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6235 comeback();
6236 return ret != 0;
6237 }
6238
6239
6240 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6241 {
6242 if(def!=modulepath)
6243 strcpy(modulepath,def);
6244
6245 if(!usefilename)
6246 {
6247 int32_t i=(int32_t)strlen(modulepath);
6248
6249 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6250 modulepath[i--]=0;
6251 }
6252
6253 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6254 int32_t ret=0;
6255 int32_t sel=0;
6256
6257 if(list==NULL)
6258 {
6259 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6260 }
6261 else
6262 {
6263 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6264 }
6265
6266 return ret!=0;
6267 }
6268
6269 //The Dialogue that loads a ZMOD Module File
6270 int32_t zc_load_zmod_module_file()
6271 {
6272 if ( Playing )
6273 {
6274 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6275 return -1;
6276 }
6277 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6278 return D_CLOSE;
6279
6280 FILE *tempmodule = fopen(modulepath,"r");
6281
6282 if(tempmodule == NULL)
6283 {
6284 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6285 return -1;
6286 }
6287
6288
6289 //Set the module path:
6290 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6291 strcpy(moduledata.module_name, modulepath);
6292 al_trace("New Module Path is: %s \n", moduledata.module_name);
6293 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6294 zcm.init(true); //Load the module values.
6295 moduledata.refresh_title_screen = 1;
6296 // refresh_select_screen = 1;
6297 build_biic_list();
6298 return D_O_K;
6299 }
6300
6301 static DIALOG module_info_dlg[] =
6302 {
6303 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6304
6305
6306 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6307 //1
6308 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6309 //2
6310 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6311 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6312 //4
6313 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6314 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6315 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6316 //7
6317
6318 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6319 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6320 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6321 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6322 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6323 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6324 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6325 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6326 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6327
6328 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6329 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6330 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6331 };
6332
6333 void about_zcplayer_module(const char *prompt,int32_t initialval)
6334 {
6335
6336 module_info_dlg[0].dp2 = lfont;
6337 if ( moduledata.moduletitle[0] != 0 )
6338 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6339
6340 if ( moduledata.moduleauthor[0] != 0 )
6341 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6342
6343 if ( moduledata.moduleinfo0[0] != 0 )
6344 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6345 if ( moduledata.moduleinfo1[0] != 0 )
6346 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6347 if ( moduledata.moduleinfo2[0] != 0 )
6348 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6349 if ( moduledata.moduleinfo3[0] != 0 )
6350 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6351 if ( moduledata.moduleinfo4[0] != 0 )
6352 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6353
6354 char module_date[255];
6355 memset(module_date, 0, sizeof(module_date));
6356 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6357 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6358
6359
6360
6361 char module_vers[255];
6362 memset(module_vers, 0, sizeof(module_vers));
6363 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6364
6365
6366 //sprintf(tilecount,"%d",1);
6367
6368 char module_build[255];
6369 memset(module_build, 0, sizeof(module_build));
6370 if ( moduledata.modbeta )
6371 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6372 else
6373 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6374
6375 module_info_dlg[12].dp = (char*)module_date;
6376 module_info_dlg[13].dp = (char*)module_vers;
6377 module_info_dlg[14].dp = (char*)module_build;
6378
6379 if(is_large)
6380 large_dialog(module_info_dlg);
6381
6382 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6383 jwin_center_dialog(module_info_dlg);
6384
6385
6386 }
6387
6388 int32_t onAbout_ZCP_Module()
6389 {
6390 about_zcplayer_module("About Module (.zmod)", 0);
6391 return D_O_K;
6392 }
6393
6394 //New Modules Menu for 2.55+
6395 static MENU zcmodule_menu[] =
6396 {
6397 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6398 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6399
6400 { NULL, NULL, NULL, 0, NULL }
6401 };
6402
6403 int32_t onToggleRecordingNewSaves()
6404 {
6405 if (zc_get_config("zeldadx", "replay_new_saves", false))
6406 {
6407 zc_set_config("zeldadx", "replay_new_saves", false);
6408 }
6409 else
6410 {
6411 zc_set_config("zeldadx", "replay_new_saves", true);
6412 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6413 NULL,NULL,"OK",NULL,13,27,lfont);
6414 }
6415 return D_O_K;
6416 }
6417
6418 int32_t onStopReplayOrRecord()
6419 {
6420 if (replay_is_replaying())
6421 {
6422 replay_quit();
6423 }
6424 else if (replay_get_mode() == ReplayMode::Record)
6425 {
6426 if (!replay_get_meta_bool("test_mode"))
6427 {
6428 jwin_alert("Recording", "You cannot stop recording a save file.",
6429 NULL,NULL,"OK",NULL,13,27,lfont);
6430 return D_CLOSE;
6431 }
6432
6433 if (jwin_alert("Stop Recording",
6434 "Save replay to disk and stop recording?",
6435 "This will stop the recording.",
6436 NULL,
6437 "Yes","No",13,27,lfont) != 1)
6438 return D_CLOSE;
6439
6440 replay_save();
6441 replay_stop();
6442 }
6443 return D_O_K;
6444 }
6445
6446 static int32_t handle_on_load_replay(ReplayMode mode)
6447 {
6448 if (Playing)
6449 {
6450 if (jwin_alert("Replay - Warning!",
6451 "Loading a replay will exit the current game.",
6452 "All unsaved progress will be lost.",
6453 "Do you wish to continue?",
6454 "Yes","No",13,27,lfont) != 1)
6455 return D_CLOSE;
6456 }
6457
6458 std::string mode_string = replay_mode_to_string(mode);
6459 mode_string[0] = std::toupper(mode_string[0]);
6460
6461 std::string line_1 = "Select a replay file to play back.";
6462 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6463 std::string line_3 = "You can stop the replay and take over manually any time.";
6464 if (mode == ReplayMode::Update)
6465 {
6466 line_1 = "Select a replay file to update.";
6467 line_2 = "WARNING: be sure to back up the zplay file";
6468 line_3 = "and verify that the updated replay works as expected!";
6469 }
6470
6471 if (jwin_alert(mode_string.c_str(),
6472 line_1.c_str(),
6473 line_2.c_str(),
6474 line_3.c_str(),
6475 "OK","Nevermind",13,27,lfont) == 1)
6476 {
6477 char replay_path[2048];
6478 strcpy(replay_path, "replays/");
6479 if (jwin_file_select_ex(
6480 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6481 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6482 return D_CLOSE;
6483
6484 replay_quit();
6485 load_replay_file_deferred(mode, replay_path);
6486 Quit = qRESET;
6487 return D_CLOSE;
6488 }
6489 return D_O_K;
6490 }
6491
6492 int32_t onLoadReplay()
6493 {
6494 return handle_on_load_replay(ReplayMode::Replay);
6495 }
6496
6497 int32_t onLoadReplayAssert()
6498 {
6499 return handle_on_load_replay(ReplayMode::Assert);
6500 }
6501
6502 int32_t onLoadReplayUpdate()
6503 {
6504 return handle_on_load_replay(ReplayMode::Update);
6505 }
6506
6507 int32_t onSaveReplay()
6508 {
6509 if (replay_get_mode() == ReplayMode::Record)
6510 {
6511 if (!replay_get_meta_bool("test_mode"))
6512 {
6513 if (jwin_alert("Save Replay",
6514 "This will save a copy of the replay up to this point.",
6515 "The official replay file will be untouched.",
6516 "Do you wish to continue?",
6517 "Yes","No",13,27,lfont) != 1)
6518 return D_CLOSE;
6519
6520 char replay_path[2048];
6521 strcpy(replay_path, replay_get_filename().c_str());
6522 if (jwin_file_select_ex(
6523 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6524 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6525 return D_CLOSE;
6526
6527 if (fileexists(replay_path))
6528 {
6529 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6530 NULL,NULL,"OK",NULL,13,27,lfont);
6531 return D_CLOSE;
6532 }
6533
6534 replay_save(replay_path);
6535 }
6536 else
6537 {
6538 replay_save();
6539 }
6540 }
6541 return D_O_K;
6542 }
6543
6544 static MENU replay_menu[] =
6545 {
6546 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6547 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6548 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6549 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6550 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6551 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6552
6553 { NULL, NULL, NULL, 0, NULL }
6554 };
6555
6556 static DIALOG credits_dlg[] =
6557 {
6558 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6559 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6560 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6561 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6562 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6563 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6564 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6565 };
6566
6567 14 static ListData dmap_list(dmaplist, &font);
6568
6569 static DIALOG goto_dlg[] =
6570 {
6571 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6572 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6573 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6574 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6575 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6576 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6577 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6578 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6579 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6580 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6581 };
6582
6583 int32_t onGoTo()
6584 {
6585 bool music = false;
6586 music = music;
6587 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6588
6589 goto_dlg[0].dp2=lfont;
6590 goto_dlg[4].d2=cheat_goto_dmap;
6591 goto_dlg[6].dp=cheat_goto_screen_str;
6592
6593 clear_keybuf();
6594
6595 if(is_large)
6596 large_dialog(goto_dlg);
6597
6598 if(zc_popup_dialog(goto_dlg,4)==1)
6599 {
6600 // dmap, screen
6601 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6602 };
6603
6604 return D_O_K;
6605 }
6606
6607 int32_t onGoToComplete()
6608 {
6609 if(!Playing)
6610 {
6611 return D_O_K;
6612 }
6613
6614 system_pal();
6615 music_pause();
6616 pause_all_sfx();
6617 show_mouse(screen);
6618 onGoTo();
6619 eat_buttons();
6620
6621 zc_readrawkey(KEY_ESC);
6622
6623 show_mouse(NULL);
6624 game_pal();
6625 music_resume();
6626 resume_all_sfx();
6627 return D_O_K;
6628 }
6629
6630 int32_t onCredits()
6631 {
6632 go();
6633
6634 BITMAP *win = create_bitmap_ex(8,222,110);
6635
6636 if(!win)
6637 return D_O_K;
6638
6639 int32_t c=0;
6640 int32_t l=0;
6641 int32_t ol=-1;
6642 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6643 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6644 PALETTE tmppal;
6645
6646 rti_gui.transparency_index = 1;
6647
6648 clear_to_color(win, rti_gui.transparency_index);
6649 draw_rle_sprite(win,rle,0,0);
6650 credits_dlg[0].dp2=lfont;
6651 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6652 credits_dlg[2].dp = win;
6653
6654 set_palette_range(black_palette,0,127,false);
6655
6656 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6657
6658 BITMAP* old_screen = screen;
6659 BITMAP* gui_bmp = zc_get_gui_bmp();
6660 ASSERT(gui_bmp);
6661 clear_to_color(gui_bmp, rti_gui.transparency_index);
6662 screen = gui_bmp;
6663
6664 while(update_dialog(p))
6665 {
6666 throttleFPS();
6667 ++c;
6668 l = zc_max((c>>1)-30,0);
6669
6670 if(l > rle->h)
6671 l = c = 0;
6672
6673 if(l > rle->h - 112)
6674 l = rle->h - 112;
6675
6676 clear_bitmap(win);
6677 draw_rle_sprite(win,rle,0,0-l);
6678
6679 if(c<=64)
6680 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6681
6682 set_palette_range(tmppal,0,127,false);
6683
6684 if(l!=ol)
6685 {
6686 scare_mouse();
6687 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6688 unscare_mouse();
6689 SCRFIX();
6690 ol=l;
6691 }
6692
6693 update_hw_screen();
6694 }
6695
6696 screen = old_screen;
6697 system_pal();
6698
6699 shutdown_dialog(p);
6700 destroy_bitmap(win);
6701 //comeback();
6702
6703 rti_gui.transparency_index = 0;
6704
6705 return D_O_K;
6706 }
6707
6708 const char *midilist(int32_t index, int32_t *list_size)
6709 {
6710 if(index<0)
6711 {
6712 *list_size=0;
6713
6714 for(int32_t i=0; i<MAXMIDIS; i++)
6715 if(tunes[i].data)
6716 ++(*list_size);
6717
6718 return NULL;
6719 }
6720
6721 int32_t i=0,m=0;
6722
6723 while(m<=index && i<=MAXMIDIS)
6724 {
6725 if(tunes[i].data)
6726 ++m;
6727
6728 ++i;
6729 }
6730
6731 --i;
6732
6733 if(i==MAXMIDIS && m<index)
6734 return "(null)";
6735
6736 return tunes[i].title;
6737 }
6738
6739 /* ------- MIDI info stuff -------- */
6740
6741 char *text;
6742 midi_info *zmi;
6743 bool dialog_running;
6744 bool listening;
6745
6746 void get_info(int32_t index);
6747
6748 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6749 {
6750 int32_t d2 = d->d2;
6751 int32_t ret = jwin_droplist_proc(msg,d,c);
6752
6753 if(d2!=d->d2)
6754 {
6755 get_info(d->d2);
6756 }
6757
6758 return ret;
6759 }
6760
6761 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6762 {
6763 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6764
6765 int32_t ret = jwin_button_proc(msg,d,c);
6766
6767 if(ret == D_CLOSE)
6768 {
6769 // get current midi index
6770 int32_t index = (d+(d->d1))->d2;
6771 int32_t i=0, m=0;
6772
6773 while(m<=index && i<=MAXMIDIS)
6774 {
6775 if(tunes[i].data)
6776 ++m;
6777
6778 ++i;
6779 }
6780
6781 --i;
6782 jukebox(i);
6783 listening = true;
6784 ret = D_O_K;
6785 }
6786
6787 return ret;
6788 }
6789
6790 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6791 {
6792 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6793
6794 int32_t ret = jwin_button_proc(msg,d,c);
6795
6796 if(ret == D_CLOSE)
6797 {
6798 // get current midi index
6799 int32_t index = (d+(d->d1))->d2;
6800 int32_t i=0, m=0;
6801
6802 while(m<=index && i<=MAXMIDIS)
6803 {
6804 if(tunes[i].data)
6805 ++m;
6806
6807 ++i;
6808 }
6809
6810 --i;
6811
6812 // get file name
6813
6814 int32_t sel=0;
6815 //struct ffblk f;
6816 char title[40] = "Save MIDI: ";
6817 char fname[2048];
6818 memset(fname,0,2048);
6819 static EXT_LIST list[] =
6820 {
6821 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6822 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6823 { NULL, NULL }
6824 };
6825
6826 strcpy(title+11, tunes[i].title);
6827 title[39] = '\0';
6828
6829 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6830 goto done;
6831
6832 if(exists(fname))
6833 {
6834 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6835 goto done;
6836 }
6837
6838 // save midi i
6839
6840 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6841 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6842
6843 done:
6844 chop_path(fname);
6845 ret = D_REDRAW;
6846 }
6847
6848 return ret;
6849 }
6850
6851 14 static ListData midi_list(midilist, &font);
6852
6853 static DIALOG midi_dlg[] =
6854 {
6855 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6856 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6857 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6858 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6859 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6860 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6861 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6862 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6863 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6864 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6865 };
6866
6867 void get_info(int32_t index)
6868 {
6869 int32_t i=0, m=0;
6870
6871 while(m<=index && i<=MAXMIDIS)
6872 {
6873 if(tunes[i].data)
6874 ++m;
6875
6876 ++i;
6877 }
6878
6879 --i;
6880
6881 if(i==MAXMIDIS && m<index)
6882 strcpy(text,"(null)");
6883 else
6884 {
6885 get_midi_info((MIDI*)tunes[i].data,zmi);
6886 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6887 }
6888
6889 midi_dlg[0].dp2=lfont;
6890 midi_dlg[3].dp = text;
6891 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6892 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6893
6894 if(dialog_running)
6895 {
6896 scare_mouse();
6897 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6898 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6899 unscare_mouse();
6900 }
6901 }
6902
6903 int32_t onMIDICredits()
6904 {
6905 text = (char*)malloc(4096);
6906 zmi = (midi_info*)malloc(sizeof(midi_info));
6907
6908 if(!text || !zmi)
6909 {
6910 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6911 return D_O_K;
6912 }
6913
6914 bool do_pause_midi = midi_pos >= 0 && currmidi;
6915 auto restore_midi = currmidi;
6916 if(do_pause_midi)
6917 {
6918 paused_midi_pos = midi_pos;
6919 stop_midi();
6920 midi_paused=true;
6921 midi_suspended = midissuspHALTED;
6922 }
6923
6924 midi_dlg[0].dp2=lfont;
6925 midi_dlg[2].d1 = 0;
6926 midi_dlg[2].d2 = 0;
6927 midi_dlg[4].flags = D_EXIT;
6928 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6929
6930 listening = false;
6931 dialog_running=false;
6932 get_info(0);
6933
6934 dialog_running=true;
6935
6936 if(is_large)
6937 large_dialog(midi_dlg);
6938
6939 zc_popup_dialog(midi_dlg,0);
6940 dialog_running=false;
6941
6942 if(listening)
6943 music_stop();
6944
6945 if(do_pause_midi)
6946 {
6947 midi_suspended = midissuspRESUME;
6948 currmidi = restore_midi;
6949 midi_pos = paused_midi_pos;
6950 }
6951
6952 if(text) free(text);
6953 if(zmi) free(zmi);
6954 return D_O_K;
6955 }
6956
6957 int32_t onAbout()
6958 {
6959 char buf1[80]={0};
6960 std::ostringstream oss;
6961 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6962 oss << buf1 << '\n';
6963 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6964 oss << buf1 << '\n';
6965 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6966 oss << buf1 << '\n';
6967 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6968 oss << buf1 << '\n';
6969
6970 InfoDialog("About ZC", oss.str()).show();
6971 return D_O_K;
6972 }
6973
6974 int32_t onQuest()
6975 {
6976 char fname[100];
6977 strcpy(fname, get_filename(qstpath));
6978 quest_dlg[0].dp2=lfont;
6979 quest_dlg[1].dp = fname;
6980
6981 if(QHeader.quest_number==0)
6982 sprintf(str_a,"Custom");
6983 else
6984 sprintf(str_a,"%d",QHeader.quest_number);
6985
6986 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6987
6988 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6989 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6990
6991 if(is_large)
6992 large_dialog(quest_dlg);
6993
6994 zc_popup_dialog(quest_dlg, 0);
6995 return D_O_K;
6996 }
6997
6998 void call_vidmode_dlg();
6999 int32_t onVidMode()
7000 {
7001 call_vidmode_dlg();
7002 return D_O_K;
7003 }
7004
7005 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7006 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7007 //Added an extra statement, so that if the key is cleared to 0, the cleared
7008 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7009
7010 void load_ukeys(int32_t* arr)
7011 {
7012 arr[ukey_a] = Akey;
7013 arr[ukey_b] = Bkey;
7014 arr[ukey_s] = Skey;
7015 arr[ukey_l] = Lkey;
7016 arr[ukey_r] = Rkey;
7017 arr[ukey_p] = Pkey;
7018 arr[ukey_ex1] = Exkey1;
7019 arr[ukey_ex2] = Exkey2;
7020 arr[ukey_ex3] = Exkey3;
7021 arr[ukey_ex4] = Exkey4;
7022 arr[ukey_du] = DUkey;
7023 arr[ukey_dd] = DDkey;
7024 arr[ukey_dl] = DLkey;
7025 arr[ukey_dr] = DRkey;
7026 arr[ukey_mod1a] = cheat_modifier_keys[0];
7027 arr[ukey_mod1b] = cheat_modifier_keys[1];
7028 arr[ukey_mod2a] = cheat_modifier_keys[2];
7029 arr[ukey_mod2b] = cheat_modifier_keys[3];
7030 };
7031
7032 static const char* ukey_names[] = {
7033 "A", "B", "Start", "L", "R", "Map",
7034 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7035 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7036 "Cheat Mod R1", "Cheat Mod R2",
7037 };
7038 std::string get_ukey_name(int32_t k)
7039 {
7040 if (k < num_ukey) return ukey_names[k];
7041 return "";
7042 }
7043
7044 int32_t onKeyboard()
7045 {
7046 int32_t a = Akey;
7047 int32_t b = Bkey;
7048 int32_t s = Skey;
7049 int32_t l = Lkey;
7050 int32_t r = Rkey;
7051 int32_t p = Pkey;
7052 int32_t ex1 = Exkey1;
7053 int32_t ex2 = Exkey2;
7054 int32_t ex3 = Exkey3;
7055 int32_t ex4 = Exkey4;
7056 int32_t du = DUkey;
7057 int32_t dd = DDkey;
7058 int32_t dl = DLkey;
7059 int32_t dr = DRkey;
7060 int32_t mod1a = cheat_modifier_keys[0];
7061 int32_t mod1b = cheat_modifier_keys[1];
7062 int32_t mod2a = cheat_modifier_keys[2];
7063 int32_t mod2b = cheat_modifier_keys[3];
7064 bool done=false;
7065 int32_t ret;
7066
7067 keyboard_control_dlg[0].dp2=lfont;
7068
7069 if(is_large)
7070 large_dialog(keyboard_control_dlg);
7071
7072 while(!done)
7073 {
7074 ret = zc_popup_dialog(keyboard_control_dlg,3);
7075
7076 if(ret==3) // OK
7077 {
7078 int32_t ukeys[num_ukey];
7079 load_ukeys(ukeys);
7080 std::vector<std::string> uniqueError;
7081 for(int32_t q = 0; q < num_ukey; ++q)
7082 {
7083 for(int32_t p = q+1; p < num_ukey; ++p)
7084 {
7085 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7086 {
7087 char buf[64];
7088 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7089 std::string str(buf);
7090 uniqueError.push_back(str);
7091 }
7092 }
7093 }
7094 if(uniqueError.size() == 0)
7095 {
7096 done = true;
7097 save_control_configs(true);
7098 }
7099 else
7100 {
7101 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7102 box_out("Cannot have duplicate keybinds!"); box_eol();
7103 for(std::vector<std::string>::iterator it = uniqueError.begin();
7104 it != uniqueError.end(); ++it)
7105 {
7106 box_out((*it).c_str()); box_eol();
7107 }
7108 box_end(true);
7109 }
7110 /* Old uniqueness check
7111 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7112 bool unique = true;
7113 addToHash(A,unique,keyhash);
7114 addToHash(B,unique,keyhash);
7115 addToHash(S,unique,keyhash);
7116 addToHash(L,unique,keyhash);
7117 addToHash(R,unique,keyhash);
7118 addToHash(P,unique,keyhash);
7119 addToHash(DU,unique,keyhash);
7120 addToHash(DD,unique,keyhash);
7121 addToHash(DL,unique,keyhash);
7122 addToHash(DR,unique,keyhash);
7123
7124 if(keyhash->find(Exkey1) == keyhash->end())
7125 {
7126 (*keyhash)[Exkey1]=true;
7127 }
7128 else
7129 {
7130 if ( Exkey1 != 0 ) unique = false;
7131 }
7132
7133 if(keyhash->find(Exkey2) == keyhash->end())
7134 {
7135 (*keyhash)[Exkey2]=true;
7136 }
7137 else
7138 {
7139 if ( Exkey2 != 0 ) unique = false;
7140 }
7141
7142 if(keyhash->find(Exkey3) == keyhash->end())
7143 {
7144 (*keyhash)[Exkey3]=true;
7145 }
7146 else
7147 {
7148 if ( Exkey3 != 0 ) unique = false;
7149 }
7150
7151 if(keyhash->find(Exkey4) == keyhash->end())
7152 {
7153 (*keyhash)[Exkey4]=true;
7154 }
7155 else
7156 {
7157 if ( Exkey4 != 0 )unique = false;
7158 }
7159 //modifier keys
7160 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7161 {
7162 (*keyhash)[cheat_modifier_keys[0]]=true;
7163 }
7164 else
7165 {
7166 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7167 }
7168 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7169 {
7170 (*keyhash)[cheat_modifier_keys[1]]=true;
7171 }
7172 else
7173 {
7174 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7175 }
7176 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7177 {
7178 (*keyhash)[cheat_modifier_keys[2]]=true;
7179 }
7180 else
7181 {
7182 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7183 }
7184 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7185 {
7186 (*keyhash)[cheat_modifier_keys[3]]=true;
7187 }
7188 else
7189 {
7190 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7191 }
7192
7193 delete keyhash;
7194
7195 if(unique)
7196 done=true;
7197 else
7198 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7199 */
7200 }
7201 else // Cancel
7202 {
7203 Akey = a;
7204 Bkey = b;
7205 Skey = s;
7206 Lkey = l;
7207 Rkey = r;
7208 Pkey = p;
7209 Exkey1 = ex1;
7210 Exkey2 = ex2;
7211 Exkey3 = ex3;
7212 Exkey4 = ex4;
7213 DUkey = du;
7214 DDkey = dd;
7215 DLkey = dl;
7216 DRkey = dr;
7217 cheat_modifier_keys[0] = mod1a;
7218 cheat_modifier_keys[1] = mod1b;
7219 cheat_modifier_keys[2] = mod2a;
7220 cheat_modifier_keys[3] = mod2b;
7221
7222 done=true;
7223 }
7224
7225 rest(1);
7226 }
7227
7228 return D_O_K;
7229 }
7230
7231 int32_t onGamepad()
7232 {
7233 int32_t a = Abtn;
7234 int32_t b = Bbtn;
7235 int32_t s = Sbtn;
7236 int32_t l = Lbtn;
7237 int32_t r = Rbtn;
7238 int32_t m = Mbtn;
7239 int32_t p = Pbtn;
7240 int32_t ex1 = Exbtn1;
7241 int32_t ex2 = Exbtn2;
7242 int32_t ex3 = Exbtn3;
7243 int32_t ex4 = Exbtn4;
7244 int32_t up = DUbtn;
7245 int32_t down = DDbtn;
7246 int32_t left = DLbtn;
7247 int32_t right = DRbtn;
7248
7249 gamepad_dlg[0].dp2=lfont;
7250 if(analog_movement)
7251 gamepad_dlg[56].flags|=D_SELECTED;
7252 else
7253 gamepad_dlg[56].flags&=~D_SELECTED;
7254
7255 if(is_large)
7256 large_dialog(gamepad_dlg);
7257
7258 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7259
7260 if(ret == 4) //OK
7261 {
7262 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7263 save_control_configs(false);
7264 }
7265 else //Cancel
7266 {
7267 Abtn = a;
7268 Bbtn = b;
7269 Sbtn = s;
7270 Lbtn = l;
7271 Rbtn = r;
7272 Mbtn = m;
7273 Pbtn = p;
7274 Exbtn1 = ex1;
7275 Exbtn2 = ex2;
7276 Exbtn3 = ex3;
7277 Exbtn4 = ex4;
7278 DUbtn = up;
7279 DDbtn = down;
7280 DLbtn = left;
7281 DRbtn = right;
7282 }
7283
7284 return D_O_K;
7285 }
7286
7287 int32_t onSound()
7288 {
7289 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7290 {
7291 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7292 }
7293 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7294 {
7295 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7296 }
7297 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7298 {
7299 emusic_volume = (int32_t)FFCore.usr_music_volume;
7300 }
7301 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7302 {
7303 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7304 }
7305 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7306 {
7307 pan_style = (int32_t)FFCore.usr_panstyle;
7308 }
7309
7310 int32_t m = midi_volume;
7311 int32_t d = digi_volume;
7312 int32_t e = emusic_volume;
7313 int32_t b = zcmusic_bufsz;
7314 int32_t s = sfx_volume;
7315 int32_t p = pan_style;
7316 pan_style = vbound(pan_style,0,3);
7317
7318 sound_dlg[0].dp2=lfont;
7319
7320 if(is_large)
7321 large_dialog(sound_dlg);
7322
7323 midi_dp[1] = sound_dlg[6].x;
7324 midi_dp[2] = sound_dlg[6].y;
7325 digi_dp[1] = sound_dlg[7].x;
7326 digi_dp[2] = sound_dlg[7].y;
7327 emus_dp[1] = sound_dlg[8].x;
7328 emus_dp[2] = sound_dlg[8].y;
7329 buf_dp[1] = sound_dlg[9].x;
7330 buf_dp[2] = sound_dlg[9].y;
7331 sfx_dp[1] = sound_dlg[10].x;
7332 sfx_dp[2] = sound_dlg[10].y;
7333 pan_dp[1] = sound_dlg[11].x;
7334 pan_dp[2] = sound_dlg[11].y;
7335 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7336 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7337 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7338 sound_dlg[18].d2 = zcmusic_bufsz;
7339 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7340 sound_dlg[20].d2 = pan_style;
7341
7342 int32_t ret = zc_popup_dialog(sound_dlg,1);
7343
7344 if(ret==2)
7345 {
7346 master_volume(digi_volume,midi_volume);
7347
7348 for(int32_t i=0; i<WAV_COUNT; ++i)
7349 {
7350 //allegro assertion fails when passing in -1 as voice -DD
7351 if(sfx_voice[i] > 0)
7352 voice_set_volume(sfx_voice[i], sfx_volume);
7353 }
7354 zc_set_config(sfx_sect,"digi",digi_volume);
7355 zc_set_config(sfx_sect,"midi",midi_volume);
7356 zc_set_config(sfx_sect,"sfx",sfx_volume);
7357 zc_set_config(sfx_sect,"emusic",emusic_volume);
7358 zc_set_config(sfx_sect,"pan",pan_style);
7359 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7360 }
7361 else
7362 {
7363 midi_volume = m;
7364 digi_volume = d;
7365 emusic_volume = e;
7366 zcmusic_bufsz = b;
7367 sfx_volume = s;
7368 pan_style = p;
7369 }
7370
7371 return D_O_K;
7372 }
7373
7374 int32_t queding(char const* s1, char const* s2, char const* s3)
7375 {
7376 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7377 }
7378
7379 int32_t onQuit()
7380 {
7381 if(Playing)
7382 {
7383 int32_t ret=0;
7384
7385 if(get_bit(quest_rules, qr_NOCONTINUE))
7386 {
7387 if(standalone_mode)
7388 {
7389 ret=queding("End current game?",
7390 "The continue screen is disabled; the game",
7391 "will be reloaded from the last save.");
7392 }
7393 else
7394 {
7395 ret=queding("End current game?",
7396 "The continue screen is disabled. You will",
7397 "be returned to the file select screen.");
7398 }
7399 }
7400 else
7401 ret=queding("End current game?",NULL,NULL);
7402
7403 if(ret==1)
7404 {
7405 disableClickToFreeze=false;
7406 Quit=qQUIT;
7407
7408 // Trying to evade a door repair charge?
7409 if(repaircharge)
7410 {
7411 game->change_drupy(-repaircharge);
7412 repaircharge=0;
7413 }
7414
7415 return D_CLOSE;
7416 }
7417 }
7418
7419 return D_O_K;
7420 }
7421
7422 int32_t onTryQuitMenu()
7423 {
7424 return onTryQuit(true);
7425 }
7426
7427 int32_t onTryQuit(bool inMenu)
7428 {
7429 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7430 {
7431 if(get_bit(quest_rules,qr_OLD_F6))
7432 {
7433 if(inMenu) onQuit();
7434 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7435 }
7436 else
7437 {
7438 disableClickToFreeze=false;
7439 GameFlags |= GAMEFLAG_TRYQUIT;
7440 }
7441 return D_CLOSE;
7442 }
7443
7444 return D_O_K;
7445 }
7446
7447 int32_t onReset()
7448 {
7449 if(queding(" Reset system? ",NULL,NULL)==1)
7450 {
7451 disableClickToFreeze=false;
7452 Quit=qRESET;
7453 replay_quit();
7454 return D_CLOSE;
7455 }
7456
7457 return D_O_K;
7458 }
7459
7460 int32_t onExit()
7461 {
7462 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7463 {
7464 Quit=qEXIT;
7465 return D_CLOSE;
7466 }
7467
7468 return D_O_K;
7469 }
7470
7471 int32_t onTitle_NES()
7472 {
7473 title_version=0;
7474 zc_set_config(cfg_sect,"title",title_version);
7475 return D_O_K;
7476 }
7477 int32_t onTitle_DX()
7478 {
7479 title_version=1;
7480 zc_set_config(cfg_sect,"title",title_version);
7481 return D_O_K;
7482 }
7483 int32_t onTitle_25()
7484 {
7485 title_version=2;
7486 zc_set_config(cfg_sect,"title",title_version);
7487 return D_O_K;
7488 }
7489
7490 int32_t onDebug()
7491 {
7492 if(debug_enabled)
7493 set_debug(!get_debug());
7494 return D_O_K;
7495 }
7496
7497 int32_t onHeartBeep()
7498 {
7499 heart_beep=!heart_beep;
7500 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7501 return D_O_K;
7502 }
7503
7504 int32_t onSaveIndicator()
7505 {
7506 use_save_indicator=!use_save_indicator;
7507 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7508 return D_O_K;
7509 }
7510
7511 int32_t onEpilepsy()
7512 {
7513 if(jwin_alert3(
7514 "Epilepsy Flash Reduction",
7515 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7516 "Disabling this will restore standard flash and wavy behaviour.",
7517 "Proceed?",
7518 "&Yes",
7519 "&No",
7520 NULL,
7521 'y',
7522 'n',
7523 0,
7524 lfont) == 1)
7525 {
7526 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7527 zc_set_config("zeldadx","checked_epilepsy",1);
7528 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7529 }
7530 return D_O_K;
7531 }
7532
7533 int32_t onTriforce()
7534 {
7535 for(int32_t i=0; i<MAXINITTABS; ++i)
7536 {
7537 init_tabs[i].flags&=~D_SELECTED;
7538 }
7539
7540 init_tabs[3].flags=D_SELECTED;
7541 return onCheatConsole();
7542 /*triforce_dlg[0].dp2=lfont;
7543 for(int32_t i=1; i<=8; i++)
7544 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7545
7546 if(zc_popup_dialog (triforce_dlg,-1)==9)
7547 {
7548 for(int32_t i=1; i<=8; i++)
7549 {
7550 game->lvlitems[i] &= ~liTRIFORCE;
7551 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7552 }
7553 }
7554 return D_O_K;*/
7555 }
7556
7557 bool rc = false;
7558 /*
7559 int32_t onEquipment()
7560 {
7561 for (int32_t i=0; i<MAXINITTABS; ++i)
7562 {
7563 init_tabs[i].flags&=~D_SELECTED;
7564 }
7565 init_tabs[0].flags=D_SELECTED;
7566 return onCheatConsole();
7567 }
7568 */
7569
7570 int32_t onItems()
7571 {
7572 for(int32_t i=0; i<MAXINITTABS; ++i)
7573 {
7574 init_tabs[i].flags&=~D_SELECTED;
7575 }
7576
7577 init_tabs[1].flags=D_SELECTED;
7578 return onCheatConsole();
7579 }
7580
7581 static DIALOG getnum_dlg[] =
7582 {
7583 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7584 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7585 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7586 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7587 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7588 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7589 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7590 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7591 };
7592
7593 int32_t getnumber(const char *prompt,int32_t initialval)
7594 {
7595 char buf[20];
7596 sprintf(buf,"%d",initialval);
7597 getnum_dlg[0].dp=(void *)prompt;
7598 getnum_dlg[0].dp2=lfont;
7599 getnum_dlg[2].dp=buf;
7600
7601 if(is_large)
7602 large_dialog(getnum_dlg);
7603
7604 if(zc_popup_dialog(getnum_dlg,2)==3)
7605 return atoi(buf);
7606
7607 return initialval;
7608 }
7609
7610 int32_t onLife()
7611 {
7612 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7613 cheats_enqueue(Cheat::Life, value);
7614 return D_O_K;
7615 }
7616
7617 int32_t onHeartC()
7618 {
7619 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7620 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7621 cheats_enqueue(Cheat::MaxLife, max_life);
7622 cheats_enqueue(Cheat::Life, life);
7623 return D_O_K;
7624 }
7625
7626 int32_t onMagicC()
7627 {
7628 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7629 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7630 cheats_enqueue(Cheat::MaxMagic, max_magic);
7631 cheats_enqueue(Cheat::Magic, magic);
7632 return D_O_K;
7633 }
7634
7635 int32_t onRupies()
7636 {
7637 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7638 cheats_enqueue(Cheat::Rupies, value);
7639 return D_O_K;
7640 }
7641
7642 int32_t onMaxBombs()
7643 {
7644 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7645 cheats_enqueue(Cheat::MaxBombs, value);
7646 cheats_enqueue(Cheat::Bombs, value);
7647 return D_O_K;
7648 }
7649
7650 int32_t onRefillLife()
7651 {
7652 cheats_enqueue(Cheat::Life, game->get_maxlife());
7653 return D_O_K;
7654 }
7655 int32_t onRefillMagic()
7656 {
7657 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7658 return D_O_K;
7659 }
7660 int32_t onClock()
7661 {
7662 cheats_enqueue(Cheat::Clock);
7663 return D_O_K;
7664 }
7665
7666 int32_t onQstPath()
7667 {
7668 char path[2048];
7669
7670 chop_path(qstdir);
7671 strcpy(path,qstdir);
7672
7673 go();
7674
7675 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7676 {
7677 chop_path(path);
7678 fix_filename_case(path);
7679 fix_filename_slashes(path);
7680 strcpy(qstdir,path);
7681 strcpy(qstpath,qstdir);
7682 }
7683
7684 comeback();
7685 return D_O_K;
7686 }
7687
7688 #include "dialog/cheat_dialog.h"
7689 int32_t onCheat()
7690 {
7691 call_setcheat_dialog();
7692 game->set_cheat(maxcheat);
7693 if(cheat) game->did_cheat(true);
7694 return D_O_K;
7695 }
7696
7697 int32_t onCheatRupies()
7698 {
7699 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7700 return D_O_K;
7701 }
7702
7703 int32_t onCheatArrows()
7704 {
7705 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7706 return D_O_K;
7707 }
7708
7709 int32_t onCheatBombs()
7710 {
7711 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7712 return D_O_K;
7713 }
7714
7715 // *** screen saver
7716
7717 123163 int32_t after_time()
7718 {
7719
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 if(ss_enable == 0)
7720 return INT_MAX;
7721
7722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
123163 if(ss_after <= 0)
7723 return 5 * 60;
7724
7725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
123163 if(ss_after <= 3)
7726 return ss_after * 15 * 60;
7727
7728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
123163 if(ss_after <= 13)
7729 return (ss_after - 3) * 60 * 60;
7730
7731 123163 return MAX_IDLE + 1;
7732 123163 }
7733
7734 static const char *after_str[15] =
7735 {
7736 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7737 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7738 "Never"
7739 };
7740
7741 const char *after_list(int32_t index, int32_t *list_size)
7742 {
7743 if(index < 0)
7744 {
7745 *list_size = 15;
7746 return NULL;
7747 }
7748
7749 return after_str[index];
7750 }
7751
7752 14 static ListData after__list(after_list, &font);
7753
7754 static DIALOG scrsaver_dlg[] =
7755 {
7756 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7757 14 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7758 14 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7759 14 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7760 14 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7761 14 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7762 14 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7763 14 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7764 14 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7765 14 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7766 14 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7767 14 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7768 14 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7769 14 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7770 };
7771
7772 int32_t onScreenSaver()
7773 {
7774 scrsaver_dlg[0].dp2=lfont;
7775 int32_t oldcfgs[3];
7776 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7777 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7778 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7779
7780 if(is_large)
7781 large_dialog(scrsaver_dlg);
7782
7783 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7784
7785 if(ret == 8 || ret == 9)
7786 {
7787 ss_after = scrsaver_dlg[5].d1;
7788 ss_speed = scrsaver_dlg[6].d2;
7789 ss_density = scrsaver_dlg[7].d2;
7790 if(oldcfgs[0] != ss_after)
7791 zc_set_config(cfg_sect,"ss_after",ss_after);
7792 if(oldcfgs[1] != ss_speed)
7793 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7794 if(oldcfgs[2] != ss_density)
7795 zc_set_config(cfg_sect,"ss_density",ss_density);
7796 }
7797
7798 if(ret == 9)
7799 // preview Screen Saver
7800 {
7801 clear_keybuf();
7802 scare_mouse();
7803 Matrix(ss_speed, ss_density, 30);
7804 system_pal();
7805 unscare_mouse();
7806 }
7807
7808 return D_O_K;
7809 }
7810
7811 /***** Menus *****/
7812
7813 static MENU game_menu[] =
7814 {
7815 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7816 { (char *)"", NULL, NULL, 0, NULL },
7817 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7818 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7819 { (char *)"", NULL, NULL, 0, NULL },
7820 #ifdef __EMSCRIPTEN__
7821 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7822 #elif defined(ALLEGRO_MACOSX)
7823 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7824 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7825 #else
7826 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7827 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7828 #endif
7829 { NULL, NULL, NULL, 0, NULL }
7830 };
7831
7832 static MENU title_menu[] =
7833 {
7834 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7835 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7836 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7837 { NULL, NULL, NULL, 0, NULL }
7838 };
7839
7840 static MENU snapshot_format_menu[] =
7841 {
7842 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7843 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7844 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7845 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7846 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7847 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7848 { NULL, NULL, NULL, 0, NULL }
7849 };
7850
7851 static MENU controls_menu[] =
7852 {
7853 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7854 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7855 { NULL, NULL, NULL, 0, NULL }
7856 };
7857
7858 static MENU name_entry_mode_menu[] =
7859 {
7860 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7861 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7862 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7863 { NULL, NULL, NULL, 0, NULL }
7864 };
7865
7866 static void set_controls_menu_active()
7867 {
7868
7869 }
7870
7871 static MENU settings_menu[] =
7872 {
7873 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7874 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7875 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7876 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7877 { (char *)"", NULL, NULL, 0, NULL },
7878 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7879 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7880 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7881 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7882 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7883 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7884 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7885 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7886 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7887 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7888 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7889 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7890 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7891 { (char *)"", NULL, NULL, 0, NULL },
7892 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7893 { (char *)"", NULL, NULL, 0, NULL },
7894 { NULL, NULL, NULL, 0, NULL }
7895 };
7896
7897
7898 static MENU misc_menu[] =
7899 {
7900 { (char *)"&About...", onAbout, NULL, 0, NULL },
7901 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7902 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7903 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7904 { (char *)"", NULL, NULL, 0, NULL },
7905 //5
7906 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7907 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7908 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7909 { (char *)"", NULL, NULL, 0, NULL },
7910 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7911 //10
7912 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7913 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7914 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7915 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7916 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7917 //15
7918 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7919 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7920 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7921
7922 { NULL, NULL, NULL, 0, NULL }
7923 };
7924
7925 static MENU refill_menu[] =
7926 {
7927 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7928 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7929 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7930 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7931 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7932 { NULL, NULL, NULL, 0, NULL }
7933 };
7934
7935 static MENU show_menu[] =
7936 {
7937 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7938 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7939 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7940 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7941 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7942 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7943 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7944 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7945 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7946 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7947 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7948 { (char *)"", NULL, NULL, 0, NULL },
7949 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7950 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7951 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7952 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7953 { NULL, NULL, NULL, 0, NULL }
7954 };
7955
7956 static MENU cheat_menu[] =
7957 {
7958 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7959 { (char *)"", NULL, NULL, 0, NULL },
7960 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7961 { (char *)"", NULL, NULL, 0, NULL },
7962 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7963 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7964 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7965 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7966 { (char *)"", NULL, NULL, 0, NULL },
7967 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7968 { (char *)"", NULL, NULL, 0, NULL },
7969 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7970 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7971 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7972 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7973 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7974 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7975 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7976 { NULL, NULL, NULL, 0, NULL }
7977 };
7978
7979 static MENU fixes_menu[] =
7980 {
7981 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7982 { NULL, NULL, NULL, 0, NULL }
7983 };
7984
7985 #if DEVLEVEL > 0
7986 int32_t devLogging();
7987 int32_t devDebug();
7988 int32_t devTimestmp();
7989 #if DEVLEVEL > 1
7990 int32_t setCheat();
7991 #endif //DEVLEVEL > 1
7992 enum
7993 {
7994 dv_log,
7995 // dv_dbg,
7996 dv_tmpstmp,
7997 #if DEVLEVEL > 1
7998 dv_nil,
7999 dv_setcheat,
8000 #endif //DEVLEVEL > 1
8001 dv_max
8002 };
8003 static MENU dev_menu[] =
8004 {
8005 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
8006 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
8007 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
8008 #if DEVLEVEL > 1
8009 { (char *)"", NULL, NULL, 0, NULL },
8010 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8011 #endif //DEVLEVEL > 1
8012 { NULL, NULL, NULL, 0, NULL }
8013 };
8014 int32_t devLogging()
8015 {
8016 dev_logging = !dev_logging;
8017 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
8018 return D_O_K;
8019 }
8020 // int32_t devDebug()
8021 // {
8022 // dev_debug = !dev_debug;
8023 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
8024 // return D_O_K;
8025 // }
8026 int32_t devTimestmp()
8027 {
8028 dev_timestmp = !dev_timestmp;
8029 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8030 return D_O_K;
8031 }
8032 #if DEVLEVEL > 1
8033 int32_t setCheat()
8034 {
8035 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8036 return D_O_K;
8037 }
8038 #endif //DEVLEVEL > 1
8039 #endif //DEVLEVEL > 0
8040
8041 MENU the_player_menu[] =
8042 {
8043 { (char *)"&Game", NULL, game_menu, 0, NULL },
8044 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8045 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8046 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8047 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8048 #if DEVLEVEL > 0
8049 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8050 #endif
8051 { NULL, NULL, NULL, 0, NULL }
8052 };
8053
8054 MENU the_player_menu2[] =
8055 {
8056 { (char *)"&Game", NULL, game_menu, 0, NULL },
8057 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8058 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8059 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8060 #if DEVLEVEL > 0
8061 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8062 #endif
8063 { NULL, NULL, NULL, 0, NULL }
8064 };
8065
8066 int32_t onMIDIPatch()
8067 {
8068 if(jwin_alert3(
8069 "Toggle Windows MIDI Fix",
8070 "This action will change whether ZC Player auto-restarts a MIDI at its",
8071 "last index if you move ZC Player out of focus, then back into focus.",
8072 "Proceed?",
8073 "&Yes",
8074 "&No",
8075 NULL,
8076 'y',
8077 'n',
8078 0,
8079 lfont) == 1)
8080 {
8081 midi_patch_fix = midi_patch_fix ? 0 : 1;
8082 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8083 }
8084 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8085 return D_O_K;
8086 }
8087
8088 int32_t onKeyboardEntry()
8089 {
8090 NameEntryMode=0;
8091 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8092 return D_O_K;
8093 }
8094
8095 int32_t onLetterGridEntry()
8096 {
8097 NameEntryMode=1;
8098 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8099 return D_O_K;
8100 }
8101
8102 int32_t onExtLetterGridEntry()
8103 {
8104 NameEntryMode=2;
8105 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8106 return D_O_K;
8107 }
8108
8109 static BITMAP* oldscreen;
8110 int32_t onFullscreenMenu()
8111 {
8112 // super hacks
8113 screen = oldscreen;
8114 if (onFullscreen() == D_REDRAW)
8115 {
8116 oldscreen = screen;
8117 }
8118 screen = menu_bmp;
8119 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8120 return D_O_K;
8121 }
8122
8123 14 void fix_menu()
8124 {
8125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!debug_enabled)
8126 14 settings_menu[18].text = NULL;
8127 14 }
8128
8129 static DIALOG system_dlg[] =
8130 {
8131 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8132 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8133 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8134 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8135 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8136 #ifndef ALLEGRO_MACOSX
8137 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8138 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8139 #else
8140 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8141 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8142 #endif
8143 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8144 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8145 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8146 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8147 };
8148
8149 static DIALOG system_dlg2[] =
8150 {
8151 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8152 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8153 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8154 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8155 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8156 #ifndef ALLEGRO_MACOSX
8157 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8158 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8159 #else
8160 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8161 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8162 #endif
8163 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8164 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8165 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8166 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8167 };
8168
8169 void reset_snapshot_format_menu()
8170 {
8171 for(int32_t i=0; i<ssfmtMAX; ++i)
8172 {
8173 snapshot_format_menu[i].flags=0;
8174 }
8175 }
8176
8177 int32_t onSetSnapshotFormat()
8178 {
8179 switch(active_menu->text[1])
8180 {
8181 case 'B': //"&BMP"
8182 SnapshotFormat=0;
8183 break;
8184
8185 case 'G': //"&GIF"
8186 SnapshotFormat=1;
8187 break;
8188
8189 case 'J': //"&JPG"
8190 SnapshotFormat=2;
8191 break;
8192
8193 case 'P': //"&PNG"
8194 SnapshotFormat=3;
8195 break;
8196
8197 case 'C': //"PC&X"
8198 SnapshotFormat=4;
8199 break;
8200
8201 case 'T': //"&TGA"
8202 SnapshotFormat=5;
8203 break;
8204
8205 case 'L': //"&LBM"
8206 SnapshotFormat=6;
8207 break;
8208 }
8209 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8210
8211 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8212 return D_O_K;
8213 }
8214
8215
8216 16 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8217 {
8218 PALETTE tmp;
8219
8220
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<256; i++)
8221 {
8222 4096 tmp[i].r=r;
8223 4096 tmp[i].g=g;
8224 4096 tmp[i].b=b;
8225 4096 }
8226
8227 16 fade_interpolate(src,tmp,dest,pos,from,to);
8228 16 }
8229
8230 16 void system_pal()
8231 {
8232 16 is_sys_pal = true;
8233 static PALETTE pal;
8234 16 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8235
8236 // set up the grayscale palette
8237
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 16 times.
1040 for(int32_t i=128; i<192; i++)
8238 {
8239 1024 pal[i].r = i-128;
8240 1024 pal[i].g = i-128;
8241 1024 pal[i].b = i-128;
8242 1024 }
8243 16 load_colorset(gui_colorset, pal);
8244
8245 16 color_layer(pal, pal, 24,16,16, 28, 128,191);
8246
8247
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 16 times.
2064 for(int32_t i=0; i<256; i+=2)
8248 {
8249 2048 int32_t v = (i>>3)+2;
8250 2048 int32_t c = (i>>3)+192;
8251 2048 pal[c] = _RGB(v,v,v+(v>>1));
8252 /*
8253 if(i<240)
8254 {
8255 _allegro_hline(tmp_scr,0,i,319,c);
8256 _allegro_hline(tmp_scr,0,i+1,319,c);
8257 }
8258 */
8259 2048 }
8260
8261 // draw the vertical screen gradient
8262
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 16 times.
3856 for(int32_t i=0; i<240; ++i)
8263 {
8264 3840 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8265 3840 }
8266
8267 /*
8268 palrstart= 10*63/255; palrend=166*63/255;
8269 palgstart= 36*63/255; palgend=202*63/255;
8270 palbstart=106*63/255; palbend=240*63/255;
8271 paldivs=32;
8272 for(int32_t i=0; i<paldivs; i++)
8273 {
8274 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8275 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8276 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8277 }
8278 */
8279 16 BITMAP *panorama = create_bitmap_ex(8,256,224);
8280 int32_t ts_height, ts_start;
8281
8282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8283 {
8284 clear_to_color(panorama,0);
8285 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8286 ts_height=224-passive_subscreen_height;
8287 ts_start=28;
8288 }
8289 else
8290 {
8291 16 blit(framebuf,panorama,0,0,0,0,256,224);
8292 16 ts_height=224;
8293 16 ts_start=0;
8294 }
8295
8296 // gray scale the current frame
8297
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 16 times.
3600 for(int32_t y=0; y<ts_height; y++)
8298 {
8299
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 3584 times.
921088 for(int32_t x=0; x<256; x++)
8300 {
8301 917504 int32_t c = panorama->line[y+ts_start][x];
8302
2/2
✓ Branch 0 taken 916942 times.
✓ Branch 1 taken 562 times.
917504 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8303 917504 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8304 917504 }
8305 3584 }
8306
8307 16 destroy_bitmap(panorama);
8308
8309 // display everything
8310 16 vsync();
8311 16 hw_palette = &pal;
8312 16 update_hw_pal = true;
8313
8314 // sys_pal = pal;
8315 16 memcpy(sys_pal,pal,sizeof(pal));
8316 16 }
8317
8318 void system_pal2()
8319 {
8320 is_sys_pal = true;
8321 static PALETTE RAMpal2;
8322 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8323
8324 /* Windows 2000 colors
8325 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8326 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8327 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8328 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8329 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8330 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8331 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8332 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8333
8334 byte palrstart= 10*63/255, palrend=166*63/255,
8335 palgstart= 36*63/255, palgend=202*63/255,
8336 palbstart=106*63/255, palbend=240*63/255,
8337 paldivs=7;
8338 for(int32_t i=0; i<paldivs; i++)
8339 {
8340 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8341 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8342 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8343 }
8344 */
8345
8346 /* Windows 98 colors
8347 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8348 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8349 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8350 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8351 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8352 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8353 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8354 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8355
8356 byte palrstart= 0*63/255, palrend=166*63/255,
8357 palgstart= 0*63/255, palgend=202*63/255,
8358 palbstart=128*63/255, palbend=240*63/255,
8359 paldivs=7;
8360 for(int32_t i=0; i<paldivs; i++)
8361 {
8362 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8363 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8364 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8365 }
8366 */
8367
8368 /* Windows 99 colors
8369 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8370 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8371 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8372 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8373 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8374 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8375 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8376 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8377 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8378
8379 byte palrstart= 0*63/255, palrend=166*63/255,
8380 palgstart= 0*63/255, palgend=202*63/255,
8381
8382 palbstart=128*63/255, palbend=240*63/255,
8383 paldivs=6;
8384 for(int32_t i=0; i<paldivs; i++)
8385 {
8386 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8387 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8388 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8389 }
8390 */
8391
8392
8393
8394 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8395 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8396 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8397 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8398 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8399 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8400 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8401 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8402 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8403
8404 byte palrstart= 0*63/255, palrend=166*63/255,
8405 palgstart= 0*63/255, palgend=202*63/255,
8406 palbstart=128*63/255, palbend=240*63/255,
8407 paldivs=6;
8408
8409 for(int32_t i=0; i<paldivs; i++)
8410 {
8411 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8412 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8413 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8414 }
8415
8416 gui_bg_color=jwin_pal[jcBOX];
8417 gui_fg_color=jwin_pal[jcBOXFG];
8418
8419 jwin_set_colors(jwin_pal);
8420
8421
8422 // set up the new palette
8423 for(int32_t i=128; i<192; i++)
8424 {
8425 RAMpal2[i].r = i-128;
8426 RAMpal2[i].g = i-128;
8427 RAMpal2[i].b = i-128;
8428 }
8429
8430 /*
8431 for(int32_t i=0; i<64; i++)
8432 {
8433 RAMpal2[128+i] = _RGB(i,i,i)1));
8434 }
8435 */
8436
8437 /*
8438
8439 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8440 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8441 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8442 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8443 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8444 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8445 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8446
8447 gui_fg_color=vc(14);
8448 gui_bg_color=vc(1);
8449
8450 jwin_set_colors(jwin_pal);
8451 */
8452
8453 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8454
8455 // set up the colors for the vertical screen gradient
8456 for(int32_t i=0; i<256; i+=2)
8457 {
8458 int32_t v = (i>>3)+2;
8459 int32_t c = (i>>3)+192;
8460 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8461
8462 /*
8463 if(i<240)
8464 {
8465 _allegro_hline(tmp_scr,0,i,319,c);
8466 _allegro_hline(tmp_scr,0,i+1,319,c);
8467 }
8468 */
8469 }
8470
8471 // hw_palette = &RAMpal;
8472 // update_hw_pal = true;
8473
8474 for(int32_t i=0; i<240; ++i)
8475 {
8476 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8477 }
8478
8479 /*
8480 byte palrstart= 10*63/255, palrend=166*63/255,
8481 palgstart= 36*63/255, palgend=202*63/255,
8482 palbstart=106*63/255, palbend=240*63/255,
8483 paldivs=32;
8484 for(int32_t i=0; i<paldivs; i++)
8485 {
8486 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8487 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8488 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8489 }
8490 */
8491 BITMAP *panorama = create_bitmap_ex(8,256,224);
8492 int32_t ts_height, ts_start;
8493
8494 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8495 {
8496 clear_to_color(panorama,0);
8497 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8498 ts_height=224-passive_subscreen_height;
8499 ts_start=28;
8500 }
8501 else
8502 {
8503 blit(framebuf,panorama,0,0,0,0,256,224);
8504 ts_height=224;
8505 ts_start=0;
8506 }
8507
8508 // gray scale the current frame
8509 for(int32_t y=0; y<ts_height; y++)
8510 {
8511 for(int32_t x=0; x<256; x++)
8512 {
8513 int32_t c = panorama->line[y+ts_start][x];
8514 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8515 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8516 }
8517 }
8518
8519 destroy_bitmap(panorama);
8520
8521 // display everything
8522 vsync();
8523 hw_palette = &RAMpal2;
8524 update_hw_pal = true;
8525
8526 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8527
8528 // sys_pal = pal;
8529 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8530 }
8531
8532 static uint32_t entered_sys_pal = 0;
8533 2 void enter_sys_pal()
8534 {
8535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(is_sys_pal)
8536 {
8537 if(entered_sys_pal)
8538 ++entered_sys_pal;
8539 return;
8540 }
8541 2 system_pal();
8542 2 ++entered_sys_pal;
8543 2 }
8544 2 void exit_sys_pal()
8545 {
8546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(entered_sys_pal)
8547 {
8548
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!--entered_sys_pal)
8549 {
8550 2 game_pal();
8551 2 }
8552 2 }
8553 2 }
8554
8555 void switch_out_callback()
8556 {
8557 if (pause_in_background)
8558 {
8559 callback_switchin = 3;
8560 return;
8561 }
8562
8563 #ifdef _WIN32
8564 if(midi_patch_fix==0 || currmidi==-1)
8565 return;
8566
8567
8568 paused_midi_pos = midi_pos;
8569 zc_stop_midi();
8570 midi_paused=true;
8571 midi_suspended = midissuspHALTED;
8572 #endif
8573 }
8574
8575 void switch_in_callback()
8576 {
8577 if(pause_in_background)
8578 {
8579 return;
8580 }
8581
8582 #ifdef _WIN32
8583 if(midi_patch_fix==0 || currmidi==-1)
8584 return;
8585
8586 else
8587 {
8588 callback_switchin = 1;
8589 midi_suspended = midissuspRESUME;
8590 }
8591 #endif
8592 }
8593
8594 35 void game_pal()
8595 {
8596 35 is_sys_pal = false;
8597 35 entered_sys_pal = 0;
8598 35 clear_to_color(screen,BLACK);
8599 35 hw_palette = &RAMpal;
8600 35 update_hw_pal = true;
8601 35 }
8602
8603 static char bar_str[] = "";
8604
8605 2 void music_pause()
8606 {
8607 //al_pause_duh(tmplayer);
8608 2 zcmusic_pause(zcmusic, ZCM_PAUSE);
8609 2 zc_midi_pause();
8610 2 midi_paused=true;
8611 2 }
8612
8613 void music_resume()
8614 {
8615 //al_resume_duh(tmplayer);
8616 zcmusic_pause(zcmusic, ZCM_RESUME);
8617 zc_midi_resume();
8618 midi_paused=false;
8619 }
8620
8621 127 void music_stop()
8622 {
8623 //al_stop_duh(tmplayer);
8624 //unload_duh(tmusic);
8625 //tmusic=NULL;
8626 //tmplayer=NULL;
8627 127 zcmusic_stop(zcmusic);
8628 127 zcmusic_unload_file(zcmusic);
8629 127 zc_stop_midi();
8630 127 midi_paused=false;
8631 127 currmidi=-1;
8632 127 }
8633
8634 void System()
8635 {
8636 mouse_down=gui_mouse_b();
8637 music_pause();
8638 pause_all_sfx();
8639 MenuOpen = true;
8640 system_pal();
8641 // FONT *oldfont=font;
8642 // font=tfont;
8643
8644 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8645 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8646
8647 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8648 #if DEVLEVEL > 1
8649 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8650 #endif
8651 game_menu[3].flags =
8652 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8653 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8654 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8655 clear_keybuf();
8656 show_mouse(screen);
8657
8658 DIALOG_PLAYER *p;
8659
8660 clear_bitmap(menu_bmp);
8661 oldscreen = screen;
8662 screen = menu_bmp;
8663
8664 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8665 {
8666 p = init_dialog(system_dlg2,-1);
8667 }
8668 else
8669 {
8670 p = init_dialog(system_dlg,-1);
8671 }
8672
8673 // drop the menu on startup if menu button pressed
8674 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8675 simulate_keypress(KEY_G << 8);
8676
8677 do
8678 {
8679 if(close_button_quit)
8680 {
8681 close_button_quit = false;
8682 f_Quit(qEXIT);
8683 if(Quit) break;
8684 }
8685 rest(17);
8686
8687 if(mouse_down && !gui_mouse_b())
8688 mouse_down=0;
8689
8690 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8691 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8692 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8693
8694 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8695 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8696 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8697 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8698 settings_menu[8].flags = NESquit?D_SELECTED:0;
8699 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8700 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8701 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8702 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8703 settings_menu[13].flags = volkeys?D_SELECTED:0;
8704 //Epilepsy Prevention
8705 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8706
8707 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8708 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8709 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8710
8711 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8712 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8713 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8714
8715 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8716 cheat_menu[0].flags = 0;
8717 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8718 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8719 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8720 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8721 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8722 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8723 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8724 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8725 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8726
8727 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8728 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8729 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8730 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8731 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8732 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8733 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8734 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8735 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8736 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8737 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8738 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8739 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8740 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8741 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8742
8743 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8744 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8745
8746 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8747 (char *)"Disable recording new saves" :
8748 (char *)"Enable recording new saves";
8749 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8750 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8751 (char *)"Stop recording" :
8752 (char *)"Stop replaying";
8753 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8754
8755 reset_snapshot_format_menu();
8756 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8757
8758 if(debug_enabled)
8759 {
8760 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8761 }
8762
8763 if(gui_mouse_b() && !mouse_down)
8764 break;
8765
8766 // press menu to drop the menu
8767 if(rMbtn())
8768 simulate_keypress(KEY_G << 8);
8769
8770 if(input_idle(true) > after_time())
8771 // run Screeen Saver
8772 {
8773 // Screen saver enabled for now.
8774 clear_keybuf();
8775 scare_mouse();
8776 Matrix(ss_speed, ss_density, 0);
8777 system_pal();
8778 unscare_mouse();
8779 broadcast_dialog_message(MSG_DRAW, 0);
8780 }
8781
8782 update_hw_screen();
8783 }
8784 while(update_dialog(p));
8785
8786 screen = oldscreen;
8787
8788 // font=oldfont;
8789 mouse_down=gui_mouse_b();
8790 shutdown_dialog(p);
8791 show_mouse(NULL);
8792 MenuOpen = false;
8793 if(Quit)
8794 {
8795 kill_sfx();
8796 music_stop();
8797 update_hw_screen();
8798 }
8799 else
8800 {
8801 game_pal();
8802 music_resume();
8803 resume_all_sfx();
8804
8805 if(rc)
8806 ringcolor(false);
8807 }
8808
8809 eat_buttons();
8810
8811 rc=false;
8812 clear_keybuf();
8813 // text_mode(0);
8814 }
8815
8816 14 void fix_dialogs()
8817 {
8818 14 jwin_center_dialog(about_dlg);
8819 14 jwin_center_dialog(gamepad_dlg);
8820 14 jwin_center_dialog(credits_dlg);
8821 14 jwin_center_dialog(gamemode_dlg);
8822 14 jwin_center_dialog(getnum_dlg);
8823 14 jwin_center_dialog(goto_dlg);
8824 14 jwin_center_dialog(keyboard_control_dlg);
8825 14 jwin_center_dialog(midi_dlg);
8826 14 jwin_center_dialog(quest_dlg);
8827 14 jwin_center_dialog(scrsaver_dlg);
8828 14 jwin_center_dialog(sound_dlg);
8829 14 jwin_center_dialog(triforce_dlg);
8830
8831 // digi_dp[1] += scrx;
8832 // digi_dp[2] += scry;
8833 // midi_dp[1] += scrx;
8834 // midi_dp[2] += scry;
8835 // pan_dp[1] += scrx;
8836 // pan_dp[2] += scry;
8837 // emus_dp[1] += scrx;
8838 // emus_dp[2] += scry;
8839 // buf_dp[1] += scrx;
8840 // buf_dp[2] += scry;
8841 // sfx_dp[1] += scrx;
8842 // sfx_dp[2] += scry;
8843 14 }
8844
8845 /*****************************/
8846 /**** Custom Sound System ****/
8847 /*****************************/
8848
8849 54 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8850 {
8851
3/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8852 }
8853
8854 // Run an NSF, or a MIDI if the NSF is missing somehow.
8855 2 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8856 {
8857 2 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8858
8859 // Found it
8860
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(newzcmusic!=NULL)
8861 {
8862 2 zcmusic_stop(zcmusic);
8863 2 zcmusic_unload_file(zcmusic);
8864 2 zc_stop_midi();
8865
8866 2 zcmusic=newzcmusic;
8867 2 zcmusic_play(zcmusic, emusic_volume);
8868
8869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(track>0)
8870 2 zcmusic_change_track(zcmusic,track);
8871
8872 2 return true;
8873 }
8874
8875 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8876 else if(midi>-1000)
8877 jukebox(midi);
8878
8879 return false;
8880 2 }
8881
8882 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8883 {
8884 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8885 // Found it
8886 if(newzcmusic!=NULL)
8887 {
8888 zcmusic_stop(zcmusic);
8889 zcmusic_unload_file(zcmusic);
8890 zc_stop_midi();
8891
8892 zcmusic=newzcmusic;
8893 zcmusic_play(zcmusic, emusic_volume);
8894
8895 if(track>0)
8896 zcmusic_change_track(zcmusic,track);
8897
8898 return true;
8899 }
8900
8901 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8902 else if(midi>-1000)
8903 jukebox(midi);
8904
8905 return false;
8906 }
8907
8908 int32_t get_zcmusicpos()
8909 {
8910 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8911 return debugtracething;
8912 return 0;
8913 }
8914
8915 void set_zcmusicpos(int32_t position)
8916 {
8917 zcmusic_set_curpos(zcmusic, position);
8918 }
8919
8920 void set_zcmusicspeed(int32_t speed)
8921 {
8922 int32_t newspeed = vbound(speed, 0, 10000);
8923 zcmusic_set_speed(zcmusic, newspeed);
8924 }
8925
8926 20 void jukebox(int32_t index,int32_t loop)
8927 {
8928 20 music_stop();
8929
8930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(index<0) index=MAXMIDIS-1;
8931
8932
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(index>=MAXMIDIS) index=0;
8933
8934 20 music_stop();
8935
8936 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8937 // stuck notes when a song stops. This fixes it.
8938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(strcmp(midi_driver->name, "DIGMID")==0)
8939 zc_set_volume(0, 0);
8940
8941 20 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8942 20 zc_play_midi((MIDI*)tunes[index].data,loop);
8943
8944
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 if(tunes[index].start>0)
8945 1 zc_midi_seek(tunes[index].start);
8946
8947 20 midi_loop_start = tunes[index].loop_start;
8948 20 midi_loop_end = tunes[index].loop_end;
8949
8950 20 currmidi=index;
8951 20 master_volume(digi_volume,midi_volume);
8952 20 midi_paused=false;
8953 20 }
8954
8955 97 void jukebox(int32_t index)
8956 {
8957
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(index<0) index=MAXMIDIS-1;
8958
8959
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(index>=MAXMIDIS) index=0;
8960
8961 // do nothing if it's already playing
8962
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
97 if(index==currmidi && midi_pos>=0)
8963 {
8964 77 midi_paused=false;
8965 77 return;
8966 }
8967
8968 20 jukebox(index,tunes[index].loop);
8969 97 }
8970
8971 156 void play_DmapMusic()
8972 {
8973 static char tfile[2048];
8974 static int32_t ttrack=0;
8975 156 bool domidi=false;
8976
8977
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 104 times.
156 if(DMaps[currdmap].tmusic[0]!=0)
8978 {
8979
3/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
85 if(zcmusic==NULL ||
8980
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8981
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8982 {
8983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(zcmusic != NULL)
8984 {
8985 zcmusic_stop(zcmusic);
8986 zcmusic_unload_file(zcmusic);
8987 zcmusic = NULL;
8988 }
8989
8990 19 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8991
8992
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 4 times.
19 if(zcmusic!=NULL)
8993 {
8994 15 zc_stop_midi();
8995 15 strcpy(tfile,DMaps[currdmap].tmusic);
8996 15 zcmusic_play(zcmusic, emusic_volume);
8997 15 int32_t temptracks=0;
8998 15 temptracks=zcmusic_get_tracks(zcmusic);
8999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 temptracks=(temptracks<2)?1:temptracks;
9000 15 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
9001 15 zcmusic_change_track(zcmusic,ttrack);
9002 15 }
9003 else
9004 {
9005 4 tfile[0] = 0;
9006 4 domidi=true;
9007 }
9008 19 }
9009 52 }
9010 else
9011 {
9012 104 domidi=true;
9013 }
9014
9015
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 108 times.
156 if(domidi)
9016 {
9017 108 int32_t m=DMaps[currdmap].midi;
9018
9019
3/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
108 switch(m)
9020 {
9021 case 1:
9022 6 jukebox(ZC_MIDI_OVERWORLD);
9023 6 break;
9024
9025 case 2:
9026 10 jukebox(ZC_MIDI_DUNGEON);
9027 10 break;
9028
9029 case 3:
9030 jukebox(ZC_MIDI_LEVEL9);
9031 break;
9032
9033 default:
9034
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
92 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9035 81 jukebox(m+MIDIOFFSET_DMAP);
9036 else
9037 11 music_stop();
9038 92 }
9039 108 }
9040 156 }
9041
9042 156 void playLevelMusic()
9043 {
9044 156 int32_t m=tmpscr->screen_midi;
9045
9046
1/6
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
156 switch(m)
9047 {
9048 case -2:
9049 music_stop();
9050 break;
9051
9052 case -1:
9053 156 play_DmapMusic();
9054 156 break;
9055
9056 case 1:
9057 jukebox(ZC_MIDI_OVERWORLD);
9058 break;
9059
9060 case 2:
9061 jukebox(ZC_MIDI_DUNGEON);
9062 break;
9063
9064 case 3:
9065 jukebox(ZC_MIDI_LEVEL9);
9066 break;
9067
9068 default:
9069 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9070 jukebox(m+MIDIOFFSET_MAPSCR);
9071 else
9072 music_stop();
9073 }
9074 156 }
9075
9076 34 void master_volume(int32_t dv,int32_t mv)
9077 {
9078
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
34 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9079
9080
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
34 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9081
9082
5/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 15 times.
34 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9083 34 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9084 34 }
9085
9086 /*****************/
9087 /***** SFX *****/
9088 /*****************/
9089
9090 // array of voices, one for each sfx sample in the data file
9091 // 0+ = voice #
9092 // -1 = voice not allocated
9093 14 void Z_init_sound()
9094 {
9095
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t i=0; i<WAV_COUNT; i++)
9096 3584 sfx_voice[i]=-1;
9097
9098
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 14 times.
112 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9099 98 tunes[i].data = (MIDI*)mididata[i].dat;
9100
9101
2/2
✓ Branch 0 taken 3528 times.
✓ Branch 1 taken 14 times.
3542 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9102 3528 tunes[ZC_MIDI_COUNT+j].data=NULL;
9103
9104 14 master_volume(digi_volume,midi_volume);
9105 14 }
9106
9107 // returns number of voices currently allocated
9108 int32_t sfx_count()
9109 {
9110 int32_t c=0;
9111
9112 for(int32_t i=0; i<WAV_COUNT; i++)
9113 if(sfx_voice[i]!=-1)
9114 ++c;
9115
9116 return c;
9117 }
9118
9119 // clean up finished samples
9120 119899 void sfx_cleanup()
9121 {
9122
2/2
✓ Branch 0 taken 30694144 times.
✓ Branch 1 taken 119899 times.
30814043 for(int32_t i=0; i<WAV_COUNT; i++)
9123
4/4
✓ Branch 0 taken 251992 times.
✓ Branch 1 taken 30442152 times.
✓ Branch 2 taken 251381 times.
✓ Branch 3 taken 611 times.
30694755 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9124 {
9125 611 deallocate_voice(sfx_voice[i]);
9126 611 sfx_voice[i]=-1;
9127 611 }
9128 119899 }
9129
9130 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9131 // if a voice is already allocated (and/or playing), then it just returns true
9132 // Returns true: voice is allocated
9133 // false: unsuccessful
9134 16469 bool sfx_init(int32_t index)
9135 {
9136 // check index
9137
3/4
✓ Branch 0 taken 15811 times.
✓ Branch 1 taken 658 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15811 times.
16469 if(index<=0 || index>=WAV_COUNT)
9138 658 return false;
9139
9140
2/2
✓ Branch 0 taken 14924 times.
✓ Branch 1 taken 887 times.
15811 if(sfx_voice[index]==-1)
9141 {
9142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 887 times.
887 if(sfxdat)
9143 {
9144 if(index<Z35)
9145 {
9146 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9147 }
9148 else
9149 {
9150 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9151 }
9152 }
9153 else
9154 {
9155 887 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9156 }
9157
9158 887 voice_set_volume(sfx_voice[index], sfx_volume);
9159 887 }
9160
9161 15811 return sfx_voice[index] != -1;
9162 16469 }
9163
9164 // plays an sfx sample
9165 7904 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9166 {
9167
2/2
✓ Branch 0 taken 7671 times.
✓ Branch 1 taken 233 times.
7904 if(!sfx_init(index))
9168 233 return;
9169
9170 7671 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9171 7671 voice_set_pan(sfx_voice[index],pan);
9172
9173 7671 int32_t pos = voice_get_position(sfx_voice[index]);
9174
9175
2/2
✓ Branch 0 taken 3610 times.
✓ Branch 1 taken 4061 times.
7671 if(restart) voice_set_position(sfx_voice[index],0);
9176
9177
2/2
✓ Branch 0 taken 3761 times.
✓ Branch 1 taken 3910 times.
7671 if(pos<=0)
9178 3761 voice_start(sfx_voice[index]);
9179 7904 }
9180
9181 // true if sfx is allocated
9182 1 bool sfx_allocated(int32_t index)
9183 {
9184
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9185 }
9186
9187 // start it (in loop mode) if it's not already playing,
9188 // otherwise adjust it to play in loop mode -DD
9189 8565 void cont_sfx(int32_t index)
9190 {
9191
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 8140 times.
8565 if(!sfx_init(index))
9192 {
9193 425 return;
9194 }
9195
9196
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 8005 times.
8140 if(voice_get_position(sfx_voice[index])<=0)
9197 {
9198 135 voice_set_position(sfx_voice[index],0);
9199 135 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9200 135 voice_start(sfx_voice[index]);
9201 135 }
9202 else
9203 {
9204 8005 adjust_sfx(index, 128, true);
9205 }
9206 8565 }
9207
9208 // adjust parameters while playing
9209 8027 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9210 {
9211
5/6
✓ Branch 0 taken 8016 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 8016 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8006 times.
✓ Branch 5 taken 10 times.
8027 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9212 21 return;
9213
9214 8006 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9215 8006 voice_set_pan(sfx_voice[index],pan);
9216 8027 }
9217
9218 // pauses a voice
9219 3 void pause_sfx(int32_t index)
9220 {
9221
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9222 voice_stop(sfx_voice[index]);
9223 3 }
9224
9225 // resumes a voice
9226 3 void resume_sfx(int32_t index)
9227 {
9228
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9229 voice_start(sfx_voice[index]);
9230 3 }
9231
9232 // pauses all active voices
9233 7 void pause_all_sfx()
9234 {
9235
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7 times.
1799 for(int32_t i=0; i<WAV_COUNT; i++)
9236
2/2
✓ Branch 0 taken 1782 times.
✓ Branch 1 taken 10 times.
1802 if(sfx_voice[i]!=-1)
9237 10 voice_stop(sfx_voice[i]);
9238 7 }
9239
9240 // resumes all paused voices
9241 5 void resume_all_sfx()
9242 {
9243
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 5 times.
1285 for(int32_t i=0; i<WAV_COUNT; i++)
9244
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 1 times.
1281 if(sfx_voice[i]!=-1)
9245 1 voice_start(sfx_voice[i]);
9246 5 }
9247
9248 // stops an sfx and deallocates the voice
9249 74394 void stop_sfx(int32_t index)
9250 {
9251
3/4
✓ Branch 0 taken 72766 times.
✓ Branch 1 taken 1628 times.
✓ Branch 2 taken 72766 times.
✗ Branch 3 not taken.
74394 if(index<=0 || index>=WAV_COUNT)
9252 1628 return;
9253
9254
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 72583 times.
72766 if(sfx_voice[index]!=-1)
9255 {
9256 183 deallocate_voice(sfx_voice[index]);
9257 183 sfx_voice[index]=-1;
9258 183 }
9259 74394 }
9260
9261 // Stops SFX played by Hero's item of the given family
9262 4160 void stop_item_sfx(int32_t family)
9263 {
9264 4160 int32_t id=current_item_id(family);
9265
9266
2/2
✓ Branch 0 taken 4149 times.
✓ Branch 1 taken 11 times.
4160 if(id<0)
9267 4149 return;
9268
9269 11 stop_sfx(itemsbuf[id].usesound);
9270 4160 }
9271
9272 56 void kill_sfx()
9273 {
9274
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 56 times.
14392 for(int32_t i=0; i<WAV_COUNT; i++)
9275
2/2
✓ Branch 0 taken 14249 times.
✓ Branch 1 taken 87 times.
14423 if(sfx_voice[i]!=-1)
9276 {
9277 87 deallocate_voice(sfx_voice[i]);
9278 87 sfx_voice[i]=-1;
9279 87 }
9280 56 }
9281
9282 6667 int32_t pan(int32_t x)
9283 {
9284
1/4
✓ Branch 0 taken 6667 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6667 switch(pan_style)
9285 {
9286 case 0:
9287 return 128;
9288
9289 case 1:
9290 6667 return vbound((x>>1)+68,0,255);
9291
9292 case 2:
9293 return vbound(((x*3)>>2)+36,0,255);
9294 }
9295
9296 return vbound(x,0,255);
9297 6667 }
9298
9299 /*******************************/
9300 /******* Input Handlers ********/
9301 /*******************************/
9302
9303 271623 bool joybtn(int32_t b)
9304 {
9305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 271623 times.
271623 if(b == 0)
9306 return false;
9307
9308 271623 return joy[joystick_index].button[b-1].b !=0;
9309 271623 }
9310
9311 const char* joybtn_name(int32_t b)
9312 {
9313 if(b == 0)
9314 return "";
9315
9316 return joy[joystick_index].button[b-1].name;
9317 }
9318
9319 int32_t next_press_key()
9320 {
9321 return readkey()>>8;
9322 }
9323
9324 int32_t next_press_btn()
9325 {
9326 clear_keybuf();
9327 /*bool b[joy[joystick_index].num_buttons+1];
9328
9329 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9330 b[i]=joybtn(i);*/
9331
9332 //first, we need to wait until they're pressing no buttons
9333 for(;;)
9334 {
9335 if(keypressed())
9336 {
9337 switch(readkey()>>8)
9338 {
9339 case KEY_ESC:
9340 return -1;
9341
9342 case KEY_SPACE:
9343 return 0;
9344 }
9345 }
9346
9347 poll_joystick();
9348 bool done = true;
9349
9350 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9351 {
9352 if(joybtn(i)) done = false;
9353 }
9354
9355 if(done) break;
9356 rest(1);
9357 }
9358
9359 //now, we need to wait for them to press any button
9360 for(;;)
9361 {
9362 if(keypressed())
9363 {
9364 switch(readkey()>>8)
9365 {
9366 case KEY_ESC:
9367 return -1;
9368
9369 case KEY_SPACE:
9370 return 0;
9371 }
9372 }
9373
9374 poll_joystick();
9375
9376 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9377 {
9378 if(joybtn(i)) return i;
9379 }
9380 rest(1);
9381 }
9382 }
9383
9384 2420974 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9385 {
9386
2/2
✓ Branch 0 taken 2316199 times.
✓ Branch 1 taken 104775 times.
2420974 bool ret = btn && !flag;
9387
2/2
✓ Branch 0 taken 2326795 times.
✓ Branch 1 taken 94179 times.
2420974 flag = rawbtn ? *rawbtn : btn;
9388
9389 2420974 return ret;
9390 }
9391 864 static bool rButtonPeek(bool btn, bool flag)
9392 {
9393
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 36 times.
864 if(!btn)
9394 {
9395 828 return false;
9396 }
9397
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9398 {
9399 9 return true;
9400 }
9401
9402 27 return false;
9403 864 }
9404
9405 // Updated only by keyboard/gamepad.
9406 // If in replay mode, this is set directly by the replay system.
9407 // This should never be read from directly - use control_state instead.
9408 bool raw_control_state[ZC_CONTROL_STATES];
9409
9410 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9411 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9412 // lasts until the next call to load_control_state.
9413 bool control_state[ZC_CONTROL_STATES];
9414 bool disable_control[ZC_CONTROL_STATES];
9415 bool drunk_toggle_state[11];
9416 bool disabledKeys[127];
9417 bool KeyInput[127];
9418 bool KeyPress[127];
9419
9420 bool key_current_frame[127];
9421 bool key_previous_frame[127];
9422
9423 static bool key_system[127];
9424 static bool key_system_previous[127];
9425 static bool key_system_press[127];
9426
9427 bool button_press[ZC_CONTROL_STATES];
9428 bool button_hold[ZC_CONTROL_STATES];
9429
9430 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9431 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9432 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9433 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9434 #define STICK_PRECISION 56 //define your own sensitivity
9435
9436 98855 void load_control_state()
9437 {
9438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98855 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98855 if (!replay_is_recording() || replay_get_version() >= 8)
9439 {
9440
2/2
✓ Branch 0 taken 1779390 times.
✓ Branch 1 taken 98855 times.
1878245 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9441 1779390 down_control_states[i] = raw_control_state[i];
9442 98855 }
9443
9444
1/2
✓ Branch 0 taken 98855 times.
✗ Branch 1 not taken.
98855 if (!replay_is_replaying())
9445 {
9446 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9447 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9448 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9449 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9450 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9451 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9452 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9453 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9454 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9455 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9456 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9457 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9458 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9459 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9460
9461 if(num_joysticks != 0)
9462 {
9463 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9464 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9465 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9466 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9467 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9468 }
9469 else
9470 {
9471 raw_control_state[14] = false;
9472 raw_control_state[15] = false;
9473 raw_control_state[16] = false;
9474 raw_control_state[17] = false;
9475 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9476 }
9477 }
9478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98855 times.
98855 if (replay_is_active())
9479 {
9480
2/2
✓ Branch 0 taken 27175 times.
✓ Branch 1 taken 71680 times.
98855 if (replay_get_version() < 3)
9481 27175 replay_poll();
9482
3/4
✓ Branch 0 taken 71680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34595 times.
✓ Branch 3 taken 37085 times.
71680 else if (replay_is_replaying() && replay_get_version() < 6)
9483 37085 replay_peek_input();
9484
3/4
✓ Branch 0 taken 34595 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20871 times.
✓ Branch 3 taken 13724 times.
34595 else if (replay_is_replaying() && replay_get_version() >= 8)
9485 13724 replay_peek_input();
9486 98855 }
9487
9488
3/4
✓ Branch 0 taken 98855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13724 times.
✓ Branch 3 taken 85131 times.
98855 if (!replay_is_active() || replay_get_version() >= 8)
9489 13724 update_keys();
9490
9491 // Some test replay files were made before a serious input bug was fixed, so instead
9492 // of re-doing them or tossing them out, just check for that zplay version.
9493
3/4
✓ Branch 0 taken 98855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4437 times.
✓ Branch 3 taken 94418 times.
98855 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9494
2/2
✓ Branch 0 taken 98855 times.
✓ Branch 1 taken 1779390 times.
1878245 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9495 {
9496 1779390 control_state[i] = raw_control_state[i];
9497
4/4
✓ Branch 0 taken 1452492 times.
✓ Branch 1 taken 326898 times.
✓ Branch 2 taken 75490 times.
✓ Branch 3 taken 1377002 times.
1779390 if (botched_input && !control_state[i])
9498 1377002 down_control_states[i] = false;
9499 1779390 }
9500
9501 98855 button_press[0]=rButton(control_state[0],button_hold[0]);
9502 98855 button_press[1]=rButton(control_state[1],button_hold[1]);
9503 98855 button_press[2]=rButton(control_state[2],button_hold[2]);
9504 98855 button_press[3]=rButton(control_state[3],button_hold[3]);
9505 98855 button_press[4]=rButton(control_state[4],button_hold[4]);
9506 98855 button_press[5]=rButton(control_state[5],button_hold[5]);
9507 98855 button_press[6]=rButton(control_state[6],button_hold[6]);
9508 98855 button_press[7]=rButton(control_state[7],button_hold[7]);
9509 98855 button_press[8]=rButton(control_state[8],button_hold[8]);
9510 98855 button_press[9]=rButton(control_state[9],button_hold[9]);
9511 98855 button_press[10]=rButton(control_state[10],button_hold[10]);
9512 98855 button_press[11]=rButton(control_state[11],button_hold[11]);
9513 98855 button_press[12]=rButton(control_state[12],button_hold[12]);
9514 98855 button_press[13]=rButton(control_state[13],button_hold[13]);
9515 98855 button_press[14]=rButton(control_state[14],button_hold[14]);
9516 98855 button_press[15]=rButton(control_state[15],button_hold[15]);
9517 98855 button_press[16]=rButton(control_state[16],button_hold[16]);
9518 98855 button_press[17]=rButton(control_state[17],button_hold[17]);
9519 98855 }
9520
9521 // Returns true if any game key is pressed. This is needed because keypressed()
9522 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9523 481435 bool zc_key_pressed()
9524 //may also need to use zc_getrawkey
9525 {
9526
7/10
✓ Branch 0 taken 384505 times.
✓ Branch 1 taken 96930 times.
✓ Branch 2 taken 96930 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96930 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 81352 times.
✓ Branch 7 taken 81352 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 26800 times.
508235 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9527
4/6
✓ Branch 0 taken 81352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81352 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59911 times.
✓ Branch 5 taken 59911 times.
81352 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9528
4/6
✓ Branch 0 taken 59911 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59911 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34634 times.
✓ Branch 5 taken 34634 times.
59911 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9529
4/6
✓ Branch 0 taken 34634 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34634 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29472 times.
✓ Branch 5 taken 29472 times.
34634 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9530
1/2
✓ Branch 0 taken 29472 times.
✗ Branch 1 not taken.
29472 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9531
3/4
✓ Branch 0 taken 27400 times.
✓ Branch 1 taken 2072 times.
✓ Branch 2 taken 27400 times.
✗ Branch 3 not taken.
29472 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9532
3/4
✓ Branch 0 taken 26911 times.
✓ Branch 1 taken 489 times.
✓ Branch 2 taken 26911 times.
✗ Branch 3 not taken.
27400 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9533
2/4
✓ Branch 0 taken 26911 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26911 times.
✗ Branch 3 not taken.
26911 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9534
3/4
✓ Branch 0 taken 26877 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 26877 times.
✗ Branch 3 not taken.
26911 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9535
3/4
✓ Branch 0 taken 26826 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 26826 times.
✗ Branch 3 not taken.
26877 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9536
2/4
✓ Branch 0 taken 26826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26826 times.
✗ Branch 3 not taken.
26826 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9537
3/4
✓ Branch 0 taken 26800 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 26800 times.
✗ Branch 3 not taken.
26826 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9538
2/4
✓ Branch 0 taken 26800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26800 times.
✗ Branch 3 not taken.
26800 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9539
1/2
✓ Branch 0 taken 26800 times.
✗ Branch 1 not taken.
26800 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9540 865373 return true;
9541
9542 26800 return false;
9543 123163 }
9544
9545 1733880 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9546 {
9547 1733880 bool ret = false, drunkstate = false, rawret = false;
9548 1733880 bool* flag = &down_control_states[btn];
9549
2/7
✓ Branch 0 taken 1610599 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 123281 times.
1733880 switch(btn)
9550 {
9551 case btnF12:
9552 ret = zc_getkey(KEY_F12, ignoreDisable);
9553 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9554 eatEntirely = false;
9555 break;
9556 case btnF11:
9557 ret = zc_getkey(KEY_F11, ignoreDisable);
9558 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9559 eatEntirely = false;
9560 break;
9561 case btnF5:
9562 ret = zc_getkey(KEY_F5, ignoreDisable);
9563 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9564 eatEntirely = false;
9565 break;
9566 case btnQ:
9567 ret = zc_getkey(KEY_Q, ignoreDisable);
9568 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9569 eatEntirely = false;
9570 break;
9571 case btnI:
9572 ret = zc_getkey(KEY_I, ignoreDisable);
9573 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9574 eatEntirely = false;
9575 break;
9576 case btnM:
9577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123281 times.
123281 if(FFCore.kb_typing_mode) return false;
9578 123281 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9579 123281 eatEntirely = false;
9580 123281 break;
9581 default: //control_state[] index
9582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1610599 times.
1610599 if(FFCore.kb_typing_mode) return false;
9583
5/6
✓ Branch 0 taken 1550435 times.
✓ Branch 1 taken 60164 times.
✓ Branch 2 taken 343738 times.
✓ Branch 3 taken 1206697 times.
✓ Branch 4 taken 343738 times.
✗ Branch 5 not taken.
1610599 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9584
2/2
✓ Branch 0 taken 83314 times.
✓ Branch 1 taken 1527285 times.
1610599 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9585
4/4
✓ Branch 0 taken 1426139 times.
✓ Branch 1 taken 184460 times.
✓ Branch 2 taken 7276 times.
✓ Branch 3 taken 177184 times.
1795059 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9586 1610599 rawret = raw_control_state[btn];
9587 1610599 }
9588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1733880 times.
1733880 assert(flag);
9589
2/2
✓ Branch 0 taken 1091432 times.
✓ Branch 1 taken 642448 times.
1733880 if(press)
9590 {
9591
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 641584 times.
642448 if(peek)
9592 864 ret = rButtonPeek(ret, *flag);
9593
3/4
✓ Branch 0 taken 641584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94179 times.
✓ Branch 3 taken 547405 times.
641584 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9594 94179 else ret = rButton(ret, *flag, &rawret);
9595 642448 }
9596
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1733880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1733880 if(eatEntirely && ret) control_state[btn] = false;
9597
3/4
✓ Branch 0 taken 1245573 times.
✓ Branch 1 taken 488307 times.
✓ Branch 2 taken 1245573 times.
✗ Branch 3 not taken.
1733880 if(drunk && drunkstate) ret = !ret;
9598 1733880 return ret;
9599 1733880 }
9600
9601 23568 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9602 {
9603 23568 byte ret = 0;
9604
2/2
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 864 times.
23568 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9605
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9606
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9607
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9608
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9609
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9610
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9611
1/2
✓ Branch 0 taken 23568 times.
✗ Branch 1 not taken.
23568 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9612 23568 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9613 }
9614
9615 byte checkIntBtnVal(byte intbtn, byte vals)
9616 {
9617 return intbtn&vals;
9618 }
9619
9620 17302 bool Up()
9621 {
9622 17302 return getInput(btnUp);
9623 }
9624 2308 bool Down()
9625 {
9626 2308 return getInput(btnDown);
9627 }
9628 3263 bool Left()
9629 {
9630 3263 return getInput(btnLeft);
9631 }
9632 4428 bool Right()
9633 {
9634 4428 return getInput(btnRight);
9635 }
9636 2198 bool cAbtn()
9637 {
9638 2198 return getInput(btnA);
9639 }
9640 5482 bool cBbtn()
9641 {
9642 5482 return getInput(btnB);
9643 }
9644 bool cSbtn()
9645 {
9646 return getInput(btnS);
9647 }
9648 296 bool cLbtn()
9649 {
9650 296 return getInput(btnL);
9651 }
9652 296 bool cRbtn()
9653 {
9654 296 return getInput(btnR);
9655 }
9656 bool cPbtn()
9657 {
9658 return getInput(btnP);
9659 }
9660 bool cEx1btn()
9661 {
9662 return getInput(btnEx1);
9663 }
9664 bool cEx2btn()
9665 {
9666 return getInput(btnEx2);
9667 }
9668 bool cEx3btn()
9669 {
9670 return getInput(btnEx3);
9671 }
9672 bool cEx4btn()
9673 {
9674 return getInput(btnEx4);
9675 }
9676 bool AxisUp()
9677 {
9678 return getInput(btnAxisUp);
9679 }
9680 bool AxisDown()
9681 {
9682 return getInput(btnAxisDown);
9683 }
9684 bool AxisLeft()
9685 {
9686 return getInput(btnAxisLeft);
9687 }
9688 bool AxisRight()
9689 {
9690 return getInput(btnAxisRight);
9691 }
9692
9693 bool cMbtn()
9694 {
9695 return getInput(btnM);
9696 }
9697 bool cF12()
9698 {
9699 return getInput(btnF12);
9700 }
9701 bool cF11()
9702 {
9703 return getInput(btnF11);
9704 }
9705 bool cF5()
9706 {
9707 return getInput(btnF5);
9708 }
9709 bool cQ()
9710 {
9711 return getInput(btnQ);
9712 }
9713 bool cI()
9714 {
9715 return getInput(btnI);
9716 }
9717
9718 202 bool rUp()
9719 {
9720 202 return getInput(btnUp, true);
9721 }
9722 202 bool rDown()
9723 {
9724 202 return getInput(btnDown, true);
9725 }
9726 202 bool rLeft()
9727 {
9728 202 return getInput(btnLeft, true);
9729 }
9730 202 bool rRight()
9731 {
9732 202 return getInput(btnRight, true);
9733 }
9734 15 bool rAbtn()
9735 {
9736 15 return getInput(btnA, true);
9737 }
9738 217 bool rBbtn()
9739 {
9740 217 return getInput(btnB, true);
9741 }
9742 80406 bool rSbtn()
9743 {
9744 80406 return getInput(btnS, true);
9745 }
9746 123163 bool rMbtn()
9747 {
9748 123163 return getInput(btnM, true);
9749 }
9750 202 bool rLbtn()
9751 {
9752 202 return getInput(btnL, true);
9753 }
9754 202 bool rRbtn()
9755 {
9756 202 return getInput(btnR, true);
9757 }
9758 80505 bool rPbtn()
9759 {
9760 80505 return getInput(btnP, true);
9761 }
9762 bool rEx1btn()
9763 {
9764 return getInput(btnEx1, true);
9765 }
9766 bool rEx2btn()
9767 {
9768 return getInput(btnEx2, true);
9769 }
9770 766 bool rEx3btn()
9771 {
9772 766 return getInput(btnEx3, true);
9773 }
9774 766 bool rEx4btn()
9775 {
9776 766 return getInput(btnEx4, true);
9777 }
9778 bool rAxisUp()
9779 {
9780 return getInput(btnAxisUp, true);
9781 }
9782 bool rAxisDown()
9783 {
9784 return getInput(btnAxisDown, true);
9785 }
9786 bool rAxisLeft()
9787 {
9788 return getInput(btnAxisLeft, true);
9789 }
9790 bool rAxisRight()
9791 {
9792 return getInput(btnAxisRight, true);
9793 }
9794
9795 bool rF11()
9796 {
9797 return getInput(btnF11, true);
9798 }
9799 bool rQ()
9800 {
9801 return getInput(btnQ, true);
9802 }
9803 bool rI()
9804 {
9805 return getInput(btnI, true);
9806 }
9807
9808 206627 bool DrunkUp()
9809 {
9810 206627 return getInput(btnUp, false, true);
9811 }
9812 189840 bool DrunkDown()
9813 {
9814 189840 return getInput(btnDown, false, true);
9815 }
9816 114377 bool DrunkLeft()
9817 {
9818 114377 return getInput(btnLeft, false, true);
9819 }
9820 98532 bool DrunkRight()
9821 {
9822 98532 return getInput(btnRight, false, true);
9823 }
9824 88084 bool DrunkcAbtn()
9825 {
9826 88084 return getInput(btnA, false, true);
9827 }
9828 92579 bool DrunkcBbtn()
9829 {
9830 92579 return getInput(btnB, false, true);
9831 }
9832 80209 bool DrunkcEx1btn()
9833 {
9834 80209 return getInput(btnEx1, false, true);
9835 }
9836 80209 bool DrunkcEx2btn()
9837 {
9838 80209 return getInput(btnEx2, false, true);
9839 }
9840 bool DrunkcSbtn()
9841 {
9842 return getInput(btnS, false, true);
9843 }
9844 bool DrunkcMbtn()
9845 {
9846 return getInput(btnM, false, true);
9847 }
9848 bool DrunkcLbtn()
9849 {
9850 return getInput(btnL, false, true);
9851 }
9852 bool DrunkcRbtn()
9853 {
9854 return getInput(btnR, false, true);
9855 }
9856 bool DrunkcPbtn()
9857 {
9858 return getInput(btnP, false, true);
9859 }
9860
9861 bool DrunkrUp()
9862 {
9863 return getInput(btnUp, true, true);
9864 }
9865 bool DrunkrDown()
9866 {
9867 return getInput(btnDown, true, true);
9868 }
9869 bool DrunkrLeft()
9870 {
9871 return getInput(btnLeft, true, true);
9872 }
9873 bool DrunkrRight()
9874 {
9875 return getInput(btnRight, true, true);
9876 }
9877 67505 bool DrunkrAbtn()
9878 {
9879 67505 return getInput(btnA, true, true);
9880 }
9881 67459 bool DrunkrBbtn()
9882 {
9883 67459 return getInput(btnB, true, true);
9884 }
9885 1219 bool DrunkrEx1btn()
9886 {
9887 1219 return getInput(btnEx1, true, true);
9888 }
9889 1219 bool DrunkrEx2btn()
9890 {
9891 1219 return getInput(btnEx2, true, true);
9892 }
9893 bool DrunkrEx3btn()
9894 {
9895 return getInput(btnEx3, true, true);
9896 }
9897 bool DrunkrEx4btn()
9898 {
9899 return getInput(btnEx4, true, true);
9900 }
9901 bool DrunkrSbtn()
9902 {
9903 return getInput(btnS, true, true);
9904 }
9905 bool DrunkrMbtn()
9906 {
9907 return getInput(btnM, true, true);
9908 }
9909 78425 bool DrunkrLbtn()
9910 {
9911 78425 return getInput(btnL, true, true);
9912 }
9913 78425 bool DrunkrRbtn()
9914 {
9915 78425 return getInput(btnR, true, true);
9916 }
9917 bool DrunkrPbtn()
9918 {
9919 return getInput(btnP, true, true);
9920 }
9921
9922 118 void eat_buttons()
9923 {
9924 118 getInput(btnA, true, false, true);
9925 118 getInput(btnB, true, false, true);
9926 118 getInput(btnS, true, false, true);
9927 118 getInput(btnM, true, false, true);
9928 118 getInput(btnL, true, false, true);
9929 118 getInput(btnR, true, false, true);
9930 118 getInput(btnP, true, false, true);
9931 118 getInput(btnEx1, true, false, true);
9932 118 getInput(btnEx2, true, false, true);
9933 118 getInput(btnEx3, true, false, true);
9934 118 getInput(btnEx4, true, false, true);
9935 118 }
9936
9937 // Is true for the _first frame_ of a key press.
9938 // But! it is possible that a script manually sets the value of KeyPress,
9939 // in which case it will be restored to the "true" value based on `key_current_frame`
9940 // and `key_previous_frame` on the next frame.
9941 3 bool zc_readkey(int32_t k, bool ignoreDisable)
9942 {
9943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ignoreDisable) return KeyPress[k];
9944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 switch(k)
9945 {
9946 case KEY_F7:
9947 case KEY_F8:
9948 case KEY_F9:
9949 return KeyPress[k];
9950
9951 default:
9952
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 return KeyPress[k] && !disabledKeys[k];
9953 }
9954 3 }
9955
9956 // Is true for _every frame_ a key is held down.
9957 // But! it is possible that a script manually sets the value of KeyInput,
9958 // in which case it will be restored to the "true" value based on `key_current_frame`
9959 // on the next frame.
9960 bool zc_getkey(int32_t k, bool ignoreDisable)
9961 {
9962 if(ignoreDisable) return KeyInput[k];
9963 switch(k)
9964 {
9965 case KEY_F7:
9966 case KEY_F8:
9967 case KEY_F9:
9968 return KeyInput[k];
9969
9970 default:
9971 return KeyInput[k] && !disabledKeys[k];
9972 }
9973 }
9974
9975 // Reads (and then clears) the current frame key state directly.
9976 // Scripts can also modify `key_current_frame`.
9977 583544 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9978 {
9979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583544 times.
583544 if(zc_getrawkey(k, ignoreDisable))
9980 {
9981 _key[k]=key[k]=key_current_frame[k]=0;
9982 return true;
9983 }
9984 583544 _key[k]=key[k]=key_current_frame[k]=0;
9985 583544 return false;
9986 583544 }
9987
9988 // Reads the current frame key state directly.
9989 // Scripts can also modify `key_current_frame`.
9990 1347638 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9991 {
9992
2/2
✓ Branch 0 taken 640933 times.
✓ Branch 1 taken 706705 times.
1347638 if(ignoreDisable) return key_current_frame[k];
9993
2/2
✓ Branch 0 taken 583538 times.
✓ Branch 1 taken 123167 times.
706705 switch(k)
9994 {
9995 case KEY_F7:
9996 case KEY_F8:
9997 case KEY_F9:
9998 583538 return key_current_frame[k];
9999
10000 default:
10001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123167 times.
123167 return key_current_frame[k] && !disabledKeys[k];
10002 }
10003 1347638 }
10004
10005 // Only used for a handful of keys, like tilde and Function keys.
10006 // This state is never read within the game.
10007 // It exists so that all keyboard input still functions during replay,
10008 // without inadvertently doing things like toggling throttling if the player
10009 // presses ~
10010 240392 bool zc_get_system_key(int32_t k)
10011 {
10012 240392 return key_system[k];
10013 }
10014
10015 // True for the _first_ frame of a key press.
10016 1354793 bool zc_read_system_key(int32_t k)
10017 {
10018 1354793 return key_system_press[k];
10019 }
10020
10021 15641701 bool is_system_key(int32_t k)
10022 {
10023
2/2
✓ Branch 0 taken 14533234 times.
✓ Branch 1 taken 1108467 times.
15641701 switch (k)
10024 {
10025 case KEY_BACKQUOTE:
10026 case KEY_CLOSEBRACE:
10027 case KEY_END:
10028 case KEY_HOME:
10029 case KEY_OPENBRACE:
10030 case KEY_PGDN:
10031 case KEY_PGUP:
10032 case KEY_TAB:
10033 case KEY_TILDE:
10034 1108467 return true;
10035 }
10036 14533234 return is_Fkey(k);
10037 15641701 }
10038
10039 123163 void update_system_keys()
10040 {
10041 123163 poll_keyboard();
10042
2/2
✓ Branch 0 taken 15641701 times.
✓ Branch 1 taken 123163 times.
15764864 for (int32_t q = 0; q < 127; ++q)
10043 {
10044
2/2
✓ Branch 0 taken 2586423 times.
✓ Branch 1 taken 13055278 times.
15641701 if (!is_system_key(q))
10045 13055278 continue;
10046
10047 2586423 key_system[q] = key[q];
10048
1/2
✓ Branch 0 taken 2586423 times.
✗ Branch 1 not taken.
2586423 key_system_press[q] = key_system[q] && !key_system_previous[q];
10049 2586423 key_system_previous[q] = key_system[q];
10050 2586423 }
10051 123163 }
10052
10053 118929 void update_keys()
10054 {
10055
1/2
✓ Branch 0 taken 118929 times.
✗ Branch 1 not taken.
118929 if (!replay_is_replaying())
10056 poll_keyboard();
10057
10058
2/2
✓ Branch 0 taken 118929 times.
✓ Branch 1 taken 15103983 times.
15222912 for (int32_t q = 0; q < 127; ++q)
10059 {
10060 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10061
1/2
✓ Branch 0 taken 15103983 times.
✗ Branch 1 not taken.
15103983 if (!replay_is_replaying())
10062 key_current_frame[q] = key[q];
10063
10064
2/2
✓ Branch 0 taken 14991366 times.
✓ Branch 1 taken 112617 times.
15103983 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10065
4/4
✓ Branch 0 taken 3631 times.
✓ Branch 1 taken 15100352 times.
✓ Branch 2 taken 3630 times.
✓ Branch 3 taken 1 times.
15103983 if (KeyPress[q] && q == KEY_B) {
10066 1 int lol = 1;
10067 1 }
10068 15103983 KeyInput[q] = key_current_frame[q];
10069 15103983 key_previous_frame[q] = key_current_frame[q];
10070 15103983 }
10071 118929 }
10072
10073 bool zc_disablekey(int32_t k, bool val)
10074 {
10075 switch(k)
10076 {
10077 case KEY_F7:
10078 case KEY_F8:
10079 case KEY_F9:
10080 return false;
10081
10082 default:
10083 disabledKeys[k] = val;
10084 return true;
10085 }
10086 }
10087
10088 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10089 {
10090 timer=timer;
10091 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10092 }
10093
10094 // these are here so that copy_dialog won't choke when compiling zelda
10095 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10096 {
10097 return D_O_K;
10098 }
10099
10100 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10101 {
10102 return D_O_K;
10103 }
10104
10105 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10106 {
10107 return D_O_K;
10108 }
10109
10110 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10111 {
10112 return D_O_K;
10113 }
10114
10115 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10116 {
10117 return D_O_K;
10118 }
10119
10120 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10121 {
10122 return D_O_K;
10123 }
10124
10125 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10126 {
10127 return D_O_K;
10128 }
10129
10130 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10131 {
10132 return D_O_K;
10133 }
10134
10135 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10136 {
10137 return D_O_K;
10138 }
10139
10140 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10141 {
10142 return D_O_K;
10143 }
10144
10145 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10146 {
10147 return D_O_K;
10148 }
10149
10150 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10151 {
10152 return D_O_K;
10153 }
10154
10155 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10156 {
10157 return D_O_K;
10158 }
10159
10160 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10161 {
10162 return D_O_K;
10163 }
10164
10165 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10166 {
10167 return D_O_K;
10168 }
10169
10170 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10171 {
10172 return D_O_K;
10173 }
10174
10175 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10176 {
10177 return D_O_K;
10178 }
10179
10180 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10181 {
10182 return D_O_K;
10183 }
10184
10185 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10186 {
10187 return D_O_K;
10188 }
10189
10190 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10191 {
10192 return D_O_K;
10193 }
10194
10195 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10196 {
10197 return D_O_K;
10198 }
10199
10200 /*** end of zc_sys.cc ***/
10201
10202